[Python-3000] binascii.crc32 vs zlib.crc32
Gregory P. Smith
greg at krypto.org
Tue Mar 18 23:21:49 CET 2008
Both modules have a crc32 function. The zlib version is faster when zlib
has been compiled optimally or about the same when zlib is old or uses its C
code.
Should we ditch the binascii.crc32 version in py3k?
64bit Linux (CentOS 5.1):
$ python2.4 -m timeit 'foo="abcdefghijklmnop"*10' 'import binascii as mod'
'f = mod.crc32' 'for x in xrange(100000): f(foo)'
10 loops, best of 3: 108 msec per loop
$ python2.4 -m timeit 'foo="abcdefghijklmnop"*10' 'import zlib as mod' 'f =
mod.crc32' 'for x in xrange(100000): f(foo)'
10 loops, best of 3: 40.5 msec per loop
32bit MacOS X 10.4:
% python2.3 /usr/lib/python2.3/timeit.py 'foo="abcdefghijklmnop"*10' 'import
binascii as mod' 'f = mod.crc32' 'for x in xrange(100000): f(foo)'
10 loops, best of 3: 7.37e+04 usec per loop
% python2.3 /usr/lib/python2.3/timeit.py 'foo="abcdefghijklmnop"*10' 'import
zlib as mod' 'f = mod.crc32' 'for x in xrange(100000): f(foo)'
10 loops, best of 3: 4.62e+04 usec per loop
Removal from binascii would break things for platforms or embedded systems
wanting crc32 that don't want to include zlib. Anyone care?
What about 2.x? if we remove the redundancy in py3k i guess we deprecate
binascii.crc32 and remove in 2.7?
-gps
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20080318/8e712cce/attachment.htm
More information about the Python-3000
mailing list