diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-03-24 00:08:01 +0000 |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-03-24 00:08:01 +0000 |
commit | 3790f2d02013c945e36daf145e874270a65a26ad (patch) | |
tree | e94ab0707dd795f9e1b079832c85fd2dd8740c9d /setup.py | |
parent | bbe16966ab500ad1c2d6eb6a522afd998d1b9fa7 (diff) | |
download | cpython-3790f2d02013c945e36daf145e874270a65a26ad.tar.gz |
Have the binascii module use zlib's optimized crc32() function when available
to reduce our code size (1k data table and tiny bit of code). It falls back
to its own without zlib.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -486,9 +486,6 @@ class PyBuildExt(build_ext): # select(2); not on ancient System V exts.append( Extension('select', ['selectmodule.c']) ) - # Helper module for various ascii-encoders - exts.append( Extension('binascii', ['binascii.c']) ) - # Fred Drake's interface to the Python parser exts.append( Extension('parser', ['parsermodule.c']) ) @@ -1069,6 +1066,7 @@ class PyBuildExt(build_ext): # You can upgrade zlib to version 1.1.4 yourself by going to # http://www.gzip.org/zlib/ zlib_inc = find_file('zlib.h', [], inc_dirs) + have_zlib = False if zlib_inc is not None: zlib_h = zlib_inc[0] + '/zlib.h' version = '"0.0.0"' @@ -1090,6 +1088,7 @@ class PyBuildExt(build_ext): exts.append( Extension('zlib', ['zlibmodule.c'], libraries = ['z'], extra_link_args = zlib_extra_link_args)) + have_zlib = True else: missing.append('zlib') else: @@ -1097,6 +1096,21 @@ class PyBuildExt(build_ext): else: missing.append('zlib') + # Helper module for various ascii-encoders. Uses zlib for an optimized + # crc32 if we have it. Otherwise binascii uses its own. + if have_zlib: + extra_compile_args = ['-DUSE_ZLIB_CRC32'] + libraries = ['z'] + extra_link_args = zlib_extra_link_args + else: + extra_compile_args = [] + libraries = [] + extra_link_args = [] + exts.append( Extension('binascii', ['binascii.c'], + extra_compile_args = extra_compile_args, + libraries = libraries, + extra_link_args = extra_link_args) ) + # Gustavo Niemeyer's bz2 module. if (self.compiler.find_library_file(lib_dirs, 'bz2')): if sys.platform == "darwin": |