Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove an unused function that had been added for the now-deleted "__…
…getbuffer__" implementation.
  • Loading branch information
scoder committed Aug 3, 2020
commit df769ef591f8a21f8e39ee30c80e09d1b7e0a705
67 changes: 0 additions & 67 deletions numpy/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -753,73 +753,6 @@ cdef inline tuple PyDataType_SHAPE(dtype d):
else:
return ()

cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
# Recursive utility function used in __getbuffer__ to get format
# string. The new location in the format string is returned.

cdef dtype child
cdef int endian_detector = 1
cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
cdef tuple fields

for childname in descr.names:
fields = descr.fields[childname]
child, new_offset = fields

if (end - f) - <int>(new_offset - offset[0]) < 15:
raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")

if ((child.byteorder == c'>' and little_endian) or
(child.byteorder == c'<' and not little_endian)):
raise ValueError(u"Non-native byte order not supported")
# One could encode it in the format string and have Cython
# complain instead, BUT: < and > in format strings also imply
# standardized sizes for datatypes, and we rely on native in
# order to avoid reencoding data types based on their size.
#
# A proper PEP 3118 exporter for other clients than Cython
# must deal properly with this!

# Output padding bytes
while offset[0] < new_offset:
f[0] = 120 # "x"; pad byte
f += 1
offset[0] += 1

offset[0] += child.itemsize

if not PyDataType_HASFIELDS(child):
t = child.type_num
if end - f < 5:
raise RuntimeError(u"Format string allocated too short.")

# Until ticket #99 is fixed, use integers to avoid warnings
if t == NPY_BYTE: f[0] = 98 #"b"
elif t == NPY_UBYTE: f[0] = 66 #"B"
elif t == NPY_SHORT: f[0] = 104 #"h"
elif t == NPY_USHORT: f[0] = 72 #"H"
elif t == NPY_INT: f[0] = 105 #"i"
elif t == NPY_UINT: f[0] = 73 #"I"
elif t == NPY_LONG: f[0] = 108 #"l"
elif t == NPY_ULONG: f[0] = 76 #"L"
elif t == NPY_LONGLONG: f[0] = 113 #"q"
elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
elif t == NPY_FLOAT: f[0] = 102 #"f"
elif t == NPY_DOUBLE: f[0] = 100 #"d"
elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
elif t == NPY_OBJECT: f[0] = 79 #"O"
else:
raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
f += 1
else:
# Cython ignores struct boundary information ("T{...}"),
# so don't output it
f = _util_dtypestring(child, f, end, offset)
return f


cdef extern from "numpy/ndarrayobject.h":
PyTypeObject PyTimedeltaArrType_Type
Expand Down