rns 5
> 3^5 returns 6
> 5^3 returns 6 ..
^ is exclusive or (xor)
# 1 ^ 1 = 0
>>> 1 ^ 1
0
# 01 ^ 10 = 11
>>> 1 ^ 2
3
# 01 ^ 11 = 10
>>> 1 ^ 3
2
# 001 ^ 100 = 101
>>> 1 ^ 4
5
Christian
--
http://mail.python.org/mailman/listinfo/python-list
php. Thanks in advance.
The code is in Objects/stringobject.c:string_hash()
Christian
--
http://mail.python.org/mailman/listinfo/python-list
e issue. The author didn't think of decoding the incoming bytes to
unicode. In Python 2.x it works fine as long as the site contains ASCII
only. In Python 3.0 however an error is raised because binary data is no
longer implicitly converted to unicode.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ternal text data"?
"foo" and u"foo" are two totally different things. The former is a byte
sequence "\x66\x6f\x6f" while the latter is the text 'foo'. It just
happens that "foo" and u"foo" are equal in Python 2.x because
"foo".decode("ascii") == u"foo". In Python 3.x does it right, b"foo" is
unequal to "foo".
Christian
--
http://mail.python.org/mailman/listinfo/python-list
> Is there a, say, performance penalty in using compressed eggs?
To the contrary, it can be faster to import from a zip file than from
the file system.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
y should not be modified; changes may not
affect the values of local variables used by the interpreter.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
> I say again, show me a case of working 2.5 code where prepending u to
> an ASCII string constant that is intended to be used in a text context
> is actually worth the keystrokes.
Eventually you'll learn it the hard way. *sigh*
Christian
--
http://mail.python.org/mailman/listinfo/python-list
t_Insert(syspath, 0, path);
Py_DECREF(syspath);
Py_DECREF(path);
if (result != 0)
return NULL;
Py_RETURN_NONE;
}
Christian
--
http://mail.python.org/mailman/listinfo/python-list
You can omit this alias, too. It's not required.
__repr__ = __str__
Instead of the try/except clause I recommend colletions.defaultdict.
Defaultdict takes one callable as factory function. Since int() returns
0 it has the same effect as your code.
from collections import defaultdict
elt = defaultdict(int)
Christian
--
http://mail.python.org/mailman/listinfo/python-list
wn.
I assume that you won't notice a slow down. However my instincts tell me
that you'll hardly get a speedup, either. You have to roll your own
benchmarks to study which algorithm is faster in reality.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
p it functionally
> more similar to the old range).
The old range function returned a list. If you need the old
functionality you can use list(range(...))[].
Why do you want to slice a range anyway? The range type supports a
start, stop and step argument.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
---
str -> bytes
unicode -> str
"" -> b""
u"" -> ""
HTH
Christian
--
http://mail.python.org/mailman/listinfo/python-list
"__call__" attribute. In order to distinguish functions from
callable you can use the inspect module, in particular
inspect.isfunction(), inspect.ismethod() and inspect.isbuiltin().
Christian
--
http://mail.python.org/mailman/listinfo/python-list
so you can stick to bytes everywhere. If you didn't have to worry about
encoding and unicode in Python 2.x then you should use bytes all over
the place, too.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
a sub thread then you should use the C function
PyImport_ImportModuleNoBlock() or use sys.modules and imp.lock_held().
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Jason Scheirer schrieb:
> Yes. I know that there are the PyObject* structs defined for you
> Py_True, Py_False and Py_None in the C level. Confusingly enough, the
> integers -5 through 257 are also singletons where the is test will
> work, but any int out of that range will not.
Small ints are cac
John Machin schrieb:
> On Jan 24, 7:48 am, Roger wrote:
>>> And, just for completeness, the "is" test is canonical precisely because
>>> the interpreter guarantees there is only ever one object of type None,
>>> so an identity test is always appropriate. Even the copy module doesn't
>>> create cop
quot; raises a syntax error like "help(if)" or
"help(while)" would raise a syntax error, too.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
perfr...@gmail.com schrieb:
> but this takes just as long... any ideas ? is there a different module
> i could use that's more suitable for large dictionaries ?
> thank you very much.
Have a look at ZODB.
--
http://mail.python.org/mailman/listinfo/python-list
the next multiple of 8 bytes
due to address alignment.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Alejandro schrieb:
> Hi:
>
> I have Python program running under Linux, that create several
> threads, and I want to now the corresponding PID of the threads.
May I ask why you want to get the TID? You can't do anything useful with
it. You can't kill a thread safely, neither from within Python no
d example for well designed and object oriented
C code.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
The
NotImplemented singleton is an optimization. The interpreter just has to
compare the memory address of the returned value with the address of
NotImplemented. That's a super fast op in C.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
rom unmananged assemblies.
Seriously, 'private' and 'protected' are merely tools to stop bad
programmers from doing bad stuff. And the serve as documentation, too.
Oh, by the way, the first C++ compilers just converted C++ code to C
code. Such much about "You can't do
[1,2,3])
>>> yadda = set([3,4,5,6])
>>> blah.issubset(yadda)
False
>>> blah.difference(yadda)
set([1, 2])
>>> blah.symmetric_difference(yadda)
set([1, 2, 4, 5, 6])
Christian
--
http://mail.python.org/mailman/listinfo/python-list
o hack all the
> setup files...?
I'm sorry to inform you that Python doesn't support cross platform
compilation. Python eats its own dog food and uses Python to compile
optional extension modules.
Some guys were working on a patch. You may find something in the bug
tracker at http://bugs.python.org
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Eddie Watson schrieb:
> What's the Python function call overhead like?
Like 6, maybe 7
*scnr*
--
http://mail.python.org/mailman/listinfo/python-list
on 2.6
>
> Any thoughts?
kinterbasdb 3.2.2 and 3.3.0 are working perfectly fine with Python 2.6.
You can install it in less than 2 minutes with the usual tar -xzf &&
python2.6 setup.py install dance. I don't know if the latest versions of
kinterbasdb still support 1.5.
Christian
thomasvang...@gmail.com schrieb:
> I just recently learned python, I'm using it mainly to process huge
> <5GB txt files of ASCII information about DNA. I've decided to learn
> 3.0, but maybe I need to step back to 2.6?
>
> I'm getting exceedingly frustrated by the slow file IO behaviour of
> pytho
andrew cooke schrieb:
> so what is happening with pep 372?
>
> http://www.python.org/dev/peps/pep-0372/
It's still a draft and hasn't been implemented yet. Now is the time to
get it ready for Python 3.1 and 2.7.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
e either write "E:\\..." or r"E:\..." (note the trailing 'r').
Try this:
import subprocess
subprocess.check_call(['E:\\Programs\\muscle\\muscle.exe', '-in',
'filename', '-out', 'filename'])
Christian
--
http://mail.python.org/mailman/listinfo/python-list
hod
call obj.method() is implemented as type(obj).method(obj).
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ot copying the cStringIO.StringO to the
> target).
>
> Can you suggest a better way ?
You can overwrite some functions in order to omit attributes from a
pickle. It's all documented at
http://docs.python.org/library/pickle.html#pickling-and-unpickling-normal-class-instances
Christian
--
http://mail.python.org/mailman/listinfo/python-list
e slower and
require more memcopy ops. CPython has a deque implementation in the
collections module with is optimized for both changing both ends of a
list like object.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Stephen Hansen schrieb:
> Now, I believe Python sets *are* for all intents and purposes
> dictionaries, but I think that's just because its the easiest and most
> efficient way to implement their uniqueness properties; they took the
> very-well-tuned dictionary implementation and cut out the stuff
API. Google for "GIL" if you are interested in
more information.
> Does that also mean that there is very little extra interpreter-overhead
> to using locks (assuming they very infrequently block)? Since if you use
> the thread module direct the code doesn't seem to esca
ster you thread with Python. You need to deal with
PyThread_init_thread(), PyEval_InitThreads(), PyThreadState_New(),
PyThreadState_Clear() and PyThreadState_DeleteCurrent(). The module
Modules/threadmodule.c contains some examples.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Tim Wintle schrieb:
> Thanks for both replies,
>
> On Mon, 2009-02-09 at 15:59 +0100, Christian Heimes wrote:
>> You shouldn't use the thread module directly. It's not meant to be used
>> by a user. Please stick to the threading module. You won't notice a
>&
embedding.html should explain how
and when to initialize Python threads. Please report a documentation bug
at http://bugs.python.org/.
Christian
PS: I know a great way to learn more about Python's internal threading
CAPI: fix your code, test it and attach a doc patch to your bug report.
*hint* :)
--
http://mail.python.org/mailman/listinfo/python-list
less the
process drops it's root privileges with setuid() ASAP the process can
escape the chroot'ed environment, too.
chroot() can help with increasing security but it's not bullet proof. By
the way it's a bad idea to mount proc and sys inside a chroot ...
Christian
--
http://mail.python.org/mailman/listinfo/python-list
upports the desired
feature. Are you able to teach your webserver WebDAV by any chance? All
major HTTP server have plugins for WebDAV.
Christian
[1] http://en.wikipedia.org/wiki/Webdav
--
http://mail.python.org/mailman/listinfo/python-list
n. We are following the same path here.
Nobody is going to stop you from creating a large bundle of useful
extensions as long as you follow the licenses. In fact lots of people
may appreciate a bundle. But the Python core package will always stay
small and agile.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
or Microsoft products.
>>
>> wx on the other hand is cross platform and ergo, much more
>> complicated.
>>
>
> I think that WX is really great but there is really a great lack of a
> builder.
This isn't a Python problem - really. Please discuss your issu
on
>
> I guess that would mean *a lot* maintenance overhead so that will
> probably never.
We considered to remove optional software from the core like the email
package, TCL/TK and more. Eventually we decided against it for various
reasons. For one we don't have the resources to maintain additional
packages.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
eah, you installed the C# environment. Python is written in C, so you
have to get Visual Studio C++ 2008. However a recent version of MinGW32
is sufficient to build most extensions.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
g multiple file descriptors.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
> architectures, nor does it work when Python is built with non-gcc Unix
> compilers
ctypes works on 64bit systems, too. However it's a pain in the ... back
to write code with ctypes that works across all platforms. I used to use
ctypes for wrapper but eventually I switched to Cython.
Chr
loat( input )
> else:
> num = int( input )
> return True
>
> except ValueError:
> return False
You code doesn't check for several float representations like "1e10",
"1E10", "inf" and "nan".
Christian
--
http://mail.python.org/mailman/listinfo/python-list
r building 2.5.4 (./configure CFLAGS=-fPIC , as the error message
> suggests), ld still croaks here:
How about compiling Python as a shared library? ./configure
--enable-shared does the trick.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
> except:
>is_an_int = False
Please don't teach new Python developers to use bare excepts. In fact
never use bare excepts at all!
Christian
--
http://mail.python.org/mailman/listinfo/python-list
reset()
Do you really want to except SystemExit, KeyboardInterrupt, MemoryError
and SyntaxError?
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ut, or close sys.stdout and reopen it in 'b'
> mode, or dup(fd) it first, or whatever the right thing to do is ?
The official API to write binary data to stdout is:
>>> count = sys.stdout.buffer.write(b"abc\n")
abc
Christian
--
http://mail.python.org/mailman/listinfo/python-list
memory management system on top of the
system's malloc() system. The memory arena system is explained in great
detail in the file obmalloc.c [2].
Christian
[1] http://en.wikipedia.org/wiki/Malloc#Implementations
[2]
http://svn.python.org/view/python/branches/release25-maint/Objects/obmall
Tim Wintle wrote:
> Basically malloc() and free() are computationally expensive, so Python
> tries to call them as little as possible - but it's quite clever at
> knowing what to do - e.g. if a list has already grown large then python
> assumes it might grow large again and keeps hold of a percenta
ly increase the speed of your computer. It's going
to take at least half a decade until the tools for multi core
development are working properly and reliable.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Traceback (most recent call last):
File "", line 1, in
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0:
unexpected code byte
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ters a lot. For instance, will the
> processing code write its results to a database, ping the GUI code and
> then exit, allowing the GUI to read the database? That sounds like an
> excellent setup for processes.
A backport for Python 2.4 and 2.5 is available on pypi. Python 2.5.4 is
recomm
Casey schrieb:
> On Feb 17, 12:33 pm, Christian Heimes wrote:
>> Yes, it's really the official way. You can google up the discussion
>> between me and Guido on the python-dev list if you don't trust me. ;)
>> The docs concur with me, too.
>>
>>
if(filename.endswith("html") or filename.endswith("htm")):
> print filename
Why so complicated?
for root, dirs, files in os.walk(directory):
for filename in files:
if filename.endswith((".htm"), (".html")):
print os.path.join(root, filename)
Christian
--
http://mail.python.org/mailman/listinfo/python-list
(VC7.1), for Python 2.6 and 3.0 you
have to install Visual Studio 2008 (VC9).
The code for the _socket extension is in the Modules/ subdirectory of
the source tree.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
You
have to os.path.join(dir, file) to get an absolute path.
Anyway stop reinventing the wheel and use os.walk() as I already
explained. You can easily spot the depth with "directory.count(os.sep)".
os.path.normpath() helps you to sanitize the path before counting the
number of os.sep.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ot.count(os.sep)
for root, dirs, files in os.walk(base):
level = root.count(os.sep) - baselevel
offset = level * "../"
...
See?
Christian
--
http://mail.python.org/mailman/listinfo/python-list
did not find any
> options relating with sqlite3 of configure and Makefile.
Do you have the development files installed as well? Run "make" again
and look at the list of missing modules.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
..] non-trivial multi-threaded programs are incomprehensible for humans.
HTH
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Carl Schumann wrote:
> I could see the logic in always or never having a trailing comma. What
> I don't understand here is why only the single element case has a
> trailing comma. Any explanations please?
Does this code shad some light on the trailing comma? :)
>>> (1) == 1
True
>>> (1,) == 1
a Python program can wrap a library and use as many cores as
possible.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Mensanator wrote:
> I thought of that, but the usual Windows crap accounts for only a
> couple percent prior to the Python program running. Christian Heimes
> answer sounds more realistic.
>
> But what do I know?
Be happy that your program makes use of both cores? :]
You ca
inate became true)
threading.Condition() and threading.Event() are especially designed for
the job. Please use them appropriately.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
7;t be in the module search path.
>
> When I tell Python to load a module, is there a way to tell which
> directory the module was loaded from?
All except builtin modules have an attribute __file__ that points to the
file.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
osal seems sensible. A trivial
patch should solve the issue:
from time import sleep as _sleep
if _sys.name == "win32":
from time import clock as _time
else:
from time import time as _time
However I'm not sure about the implications.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
e
> 2.6 as
> defective.
Please don't call something dumb that you don't fully understand. It's
offenses the people who have spent lots of time developing Python --
personal, unpaid and voluntary time!
I can assure, the bytes alias and b'' alias have their right to exist.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Hendrik van Rooyen wrote:
> "Christian Heimes" wrote:
>
>> John Nagle wrote
>>>If "bytes", a new keyword, works differently in 2.6 and 3.0, that was
>>> really
>>> dumb. There's no old code using "bytes". So conver
value, lists and dicts by reference.
>
> Is there a general rule? Some common formulation?
Python uses neither call by reference nor call by value. It's called
call by sharing or call by object. http://effbot.org/zone/call-by-object.htm
Christian
--
http://mail.python.org/mailman/listinfo/python-list
To whom it might concern. Monty Python has opened an official Monty
Python channel on Youtube. http://www.youtube.com/user/MontyPython
High quality Monty Python movies - powered by Python :)
Have fun!
Christian
--
http://mail.python.org/mailman/listinfo/python-list
s this attribute gone in 3.0rc3 ?
where is this documented ?
It's now os.path.extsep.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
y which isn't suited for the Python
core. It's written in C++ and it's licensed under GPL. Neither GPL nor
LGPL software can't be integrated into the core. We also require all
code to be compatible with C89.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
e new style classes with type:
>>> Name = type("Name", (object,), dict(spam="egg"))
>>> Name
>>> Name.spam
'egg'
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Gerhard Häring wrote:
#!/bin/sh
python setup.py build
cp build/lib.*/*.so .
python test.py
"python setup.py build_ext -i" is your friend. It installs the
extensions inplace. No need for cp here. :)
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ent.split
( 'BIN;SP1;PW0.3,1;PA100,700;PD625,700;PU;' ) # This one i have neve
tried...
[/code]
Do you really mean io.StringIO? I guess you want io.BytesIO() ..
Christian
--
http://mail.python.org/mailman/listinfo/python-list
g was so slow because the
fileio_readall() was increasing the buffer by 8kB in each iteration. The
new code doubles the buffer until it reaches 512kB. Starting with 512kB
it's increased in 512kB blocks. Python 2.x has the same growth rate.
Christian
--
http://mail.python.org/mailman/listi
;ll get the fix in the next
release of Python 3.0 in a couple of weeks.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
MRAB wrote:
Does pysco with with Python 3.0 (the homepage says 2.5)? If it does then
that might help! :-)
No, it won't help.
--
http://mail.python.org/mailman/listinfo/python-list
caused by
additional code for line ending detection and decoding/encoding. The new
io library does more than the old file object
So far the new io library hasn't been optimized yet, too. Please give it
some time and report speed issues at http://bugs.python.org/.
Christian
--
http://mail.pyt
tstate__(self, state):
dict.update(self, state[0])
self.__dict__.update(state[1])
def __reduce__(self):
state = (dict(self), self.__dict__)
return (__newobj__, (self.__class__,), state)
Christian
--
http://mail.python.org/mailman/listinfo/python-list
2.6/io.py", line 1487, in write
s.__class__.__name__)
TypeError: can't write str to text stream
which has me stumped. Why can't it?
In this context 'str' means Python 3.0's str type, which is unicode in
2.x. Please report the misleading error message.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
.1. There are interesting experiments with LLVM and threaded
code (not to confuse with multithreading) going on.
Grüße an die andere Seite von Aachen
Christian
--
http://mail.python.org/mailman/listinfo/python-list
binaries doesn't have and never had an ncurses extension.
The extension doesn't suport ncurses on Windows at all - in all versions
of Python.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ay of
doing things might be useful. I'll see what I can put together based
on the responses I get here.
http://svn.python.org/view/python/branches/release25-maint/PCbuild/readme.txt?rev=51333&view=auto
Christian
--
http://mail.python.org/mailman/listinfo/python-list
e. The compiler rearranges the code. You could try to
compile your own code with different compiler arguments. I don't know if
that's easily possible on Windows with Python 2.5.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
,
> as that's what will be easy for most people to set up.
A debug build changes large parts of the ABI. Every PyObject struct
gains additional fields, lots of checks are added to Python's memory
allocation system and asserts are enabled. Debug extensions have a _d
suffix for a very good
*is* slower for now. As I already said in another thread our
top priorities were feature completeness and bug fixing. Optimizations
will follow the features in the near future.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
me insights. Make your
you read dictnotes.txt and the cmments in dictobject.c
http://svn.python.org/view/python/branches/release25-maint/Objects/
Christian
--
http://mail.python.org/mailman/listinfo/python-list
t 32 bit but usually
sizeof(ptr).
Christian
--
http://mail.python.org/mailman/listinfo/python-list
t;, "--host
mydomain", "--port 4848", "--user admin", "server-01"])
That should solve your quoting issues on Windows and fix your code.
shell=True is considered evil and should be avoided whenever possible.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
oo. It depends
on the file system. It works with NTFS but I'm not sure how FAT32 deals
with large files. My DVB-S receiver with USB port chokes on files with
more than 2 GB.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
element, the answer
> is always string. How do I point at the variables themselves. A
> quick example is:
>
> a = 5
> b = 2.0
> c = 'c'
>
> lst = dir()
>
> for el in lst:
> print type(el)
for name, obj in vars().iteritems():
print name, obj
Chris
.0. For that very reason it must
stay until 3.2. We don't have plans to deprecate it in 3.1 so it will
stay at least until Python 3.3 which is to be released about 2014.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ally different truth than mine -- and most
of the active member of the community.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
ted a few more months or even a few more years with a
3.0 release. There is always - I repeat ALWAYS - work to do. For an open
source project like Python "release early, release often" works better.
Christian
--
http://mail.python.org/mailman/listinfo/python-list
Pierre-Alain Dorange schrieb:
> I don't find any sign(x) function in the math library (return the sign
> of the value).
> I've read that math module is a wrapper to C math lib and that C math
> lib has not sign(), so...
Starting with Python 2.6 the math and cmath modules have a copysign
function.
1201 - 1300 of 1986 matches
Mail list logo