summaryrefslogtreecommitdiff
path: root/numpy/core/setup.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2013-03-21 14:23:21 +0100
committerSebastian Berg <sebastian@sipsolutions.net>2013-04-01 21:12:46 +0200
commit79d22dcef7947347660cbb953cb54ee3b38822f5 (patch)
tree01c4dbfe03fd864ad6411f0f287702abc59ff96c /numpy/core/setup.py
parent5a3ecafe1c7a57db473f926eb4be5a4040ec2344 (diff)
downloadnumpy-79d22dcef7947347660cbb953cb54ee3b38822f5.tar.gz
BLD: Add NPY_RELAXED_STRIDES_CHECKING flag
This flag will toggle to a new definition for the contiguous flags where only the memory layout is forced to be correct. As a particular example this means that np.ones((3,1)) can be both C and F-Contiguous and its stride[-1] can be arbitrary but the array still contiguous. The flag will also make most new arrays be created with MAX_INTP as stride so that unsafe usage of the stride will surface more commonly.
Diffstat (limited to 'numpy/core/setup.py')
-rw-r--r--numpy/core/setup.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 37f649e6b..c65012126 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -15,6 +15,9 @@ from setup_common import *
# Set to True to enable multiple file compilations (experimental)
ENABLE_SEPARATE_COMPILATION = (os.environ.get('NPY_SEPARATE_COMPILATION', "1") != "0")
+# Set to True to enable relaxed strides checking. This (mostly) means
+# that `strides[dim]` is ignored if `shape[dim] == 1` when setting flags.
+NPY_RELAXED_STRIDES_CHECKING = (os.environ.get('NPY_RELAXED_STRIDES_CHECKING', "0") != "0")
# XXX: ugly, we use a class to avoid calling twice some expensive functions in
# config.h/numpyconfig.h. I don't see a better way because distutils force
@@ -435,6 +438,9 @@ def configuration(parent_package='',top_path=None):
if ENABLE_SEPARATE_COMPILATION:
moredefs.append(('ENABLE_SEPARATE_COMPILATION', 1))
+ if NPY_RELAXED_STRIDES_CHECKING:
+ moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1))
+
# Get long double representation
if sys.platform != 'darwin':
rep = check_long_double_representation(config_cmd)
@@ -532,6 +538,9 @@ def configuration(parent_package='',top_path=None):
if ENABLE_SEPARATE_COMPILATION:
moredefs.append(('NPY_ENABLE_SEPARATE_COMPILATION', 1))
+ if NPY_RELAXED_STRIDES_CHECKING:
+ moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1))
+
# Check wether we can use inttypes (C99) formats
if config_cmd.check_decl('PRIdPTR', headers = ['inttypes.h']):
moredefs.append(('NPY_USE_C99_FORMATS', 1))