cython
changeset 1118:f58bacff008d
long long indexing failed when sizeof(long long) < sizeof(Py_ssize_t)
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Tue Aug 26 00:06:52 2008 -0700 (3 years ago) |
| parents | 6488f2d89e72 |
| children | ef9d512c910e |
| files | Cython/Compiler/ExprNodes.py Cython/Compiler/PyrexTypes.py tests/run/longlongindex.pyx |
line diff
1.1 --- a/Cython/Compiler/ExprNodes.py Tue Aug 19 04:13:56 2008 -0700
1.2 +++ b/Cython/Compiler/ExprNodes.py Tue Aug 26 00:06:52 2008 -0700
1.3 @@ -1423,7 +1423,7 @@
1.4 elif not skip_child_analysis:
1.5 self.index.analyse_types(env)
1.6 if self.base.type.is_pyobject:
1.7 - if self.index.type.is_int:
1.8 + if self.index.type.is_int and not self.index.type.is_longlong:
1.9 self.original_index_type = self.index.type
1.10 self.index = self.index.coerce_to(PyrexTypes.c_py_ssize_t_type, env).coerce_to_simple(env)
1.11 if getting:
2.1 --- a/Cython/Compiler/PyrexTypes.py Tue Aug 19 04:13:56 2008 -0700
2.2 +++ b/Cython/Compiler/PyrexTypes.py Tue Aug 26 00:06:52 2008 -0700
2.3 @@ -29,6 +29,7 @@
2.4 # is_extension_type boolean Is a Python extension type
2.5 # is_numeric boolean Is a C numeric type
2.6 # is_int boolean Is a C integer type
2.7 + # is_longlong boolean Is a long long or unsigned long long.
2.8 # is_float boolean Is a C floating point type
2.9 # is_void boolean Is the C void type
2.10 # is_array boolean Is a C array type
2.11 @@ -79,6 +80,7 @@
2.12 is_builtin_type = 0
2.13 is_numeric = 0
2.14 is_int = 0
2.15 + is_longlong = 0
2.16 is_float = 0
2.17 is_void = 0
2.18 is_array = 0
2.19 @@ -553,12 +555,14 @@
2.20
2.21 class CLongLongType(CUIntType):
2.22
2.23 + is_longlong = 1
2.24 to_py_function = "PyLong_FromLongLong"
2.25 from_py_function = "__pyx_PyInt_AsLongLong"
2.26
2.27
2.28 class CULongLongType(CUIntType):
2.29
2.30 + is_longlong = 1
2.31 to_py_function = "PyLong_FromUnsignedLongLong"
2.32 from_py_function = "__pyx_PyInt_AsUnsignedLongLong"
2.33
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tests/run/longlongindex.pyx Tue Aug 26 00:06:52 2008 -0700
3.3 @@ -0,0 +1,18 @@
3.4 +__doc__ = """
3.5 + >>> D = set_longlong(2**40, 2**50, 2, "yelp")
3.6 + >>> D[2**40]
3.7 + 'yelp'
3.8 + >>> D[2**50]
3.9 + 'yelp'
3.10 + >>> D[2]
3.11 + 'yelp'
3.12 +"""
3.13 +
3.14 +ctypedef long long foo
3.15 +
3.16 +def set_longlong(long long ob, foo x, long y, val):
3.17 + tank = {}
3.18 + tank[ob] = val
3.19 + tank[x] = val
3.20 + tank[y] = val
3.21 + return tank
