diff options
author | David Cournapeau <cournape@gmail.com> | 2009-02-26 14:07:23 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2009-02-26 14:07:23 +0000 |
commit | e122cedce5154ac7c4e9fb6cc8316d4574b7f071 (patch) | |
tree | 1c88a9be6d30aa755c1214cd7243328bb92e7607 /numpy | |
parent | 22dd86ab5e2c52aff12472d5043dc5145d4a2aad (diff) | |
download | numpy-e122cedce5154ac7c4e9fb6cc8316d4574b7f071.tar.gz |
Use hints for sizeof checks, to speed things up.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/setup.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py index c58273fac..19da50fc5 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -180,6 +180,20 @@ def check_types(config_cmd, ext, build_dir): private_defines = [] public_defines = [] + # Expected size (in number of bytes) for each type. This is an + # optimization: those are only hints, and an exhaustive search for the size + # is done if the hints are wrong. + expected = {} + expected['short'] = [2] + expected['int'] = [4] + expected['long'] = [8, 4] + expected['float'] = [4] + expected['double'] = [8] + expected['long double'] = [8, 12, 16] + expected['Py_intptr_t'] = [4, 8] + expected['PY_LONG_LONG'] = [8] + expected['long long'] = [8] + # Check we have the python header (-dev* packages on Linux) result = config_cmd.check_header('Python.h') if not result: @@ -189,7 +203,7 @@ def check_types(config_cmd, ext, build_dir): # Check basic types sizes for type in ('short', 'int', 'long', 'float', 'double', 'long double'): - res = config_cmd.check_type_size(type) + res = config_cmd.check_type_size(type, expected=expected[type]) if res >= 0: if not type == 'long double': private_defines.append(('SIZEOF_%s' % sym2def(type), '%d' % res)) @@ -199,7 +213,9 @@ def check_types(config_cmd, ext, build_dir): for type in ('Py_intptr_t',): res = config_cmd.check_type_size(type, headers=["Python.h"], - library_dirs=[pythonlib_dir()]) + library_dirs=[pythonlib_dir()], + expected=expected[type]) + if res >= 0: private_defines.append(('SIZEOF_%s' % sym2def(type), '%d' % res)) public_defines.append(('NPY_SIZEOF_%s' % sym2def(type), '%d' % res)) @@ -209,14 +225,16 @@ def check_types(config_cmd, ext, build_dir): # We check declaration AND type because that's how distutils does it. if config_cmd.check_decl('PY_LONG_LONG', headers=['Python.h']): res = config_cmd.check_type_size('PY_LONG_LONG', headers=['Python.h'], - library_dirs=[pythonlib_dir()]) + library_dirs=[pythonlib_dir()], + expected=expected['PY_LONG_LONG']) if res >= 0: private_defines.append(('SIZEOF_%s' % sym2def('PY_LONG_LONG'), '%d' % res)) public_defines.append(('NPY_SIZEOF_%s' % sym2def('PY_LONG_LONG'), '%d' % res)) else: raise SystemError("Checking sizeof (%s) failed !" % 'PY_LONG_LONG') - res = config_cmd.check_type_size('long long') + res = config_cmd.check_type_size('long long', + expected=expected['long long']) if res >= 0: #private_defines.append(('SIZEOF_%s' % sym2def('long long'), '%d' % res)) public_defines.append(('NPY_SIZEOF_%s' % sym2def('long long'), '%d' % res)) |