numpy  2.0.0
src/multiarray/descriptor.c File Reference
#include <Python.h>
#include "structmember.h"
#include "numpy/arrayobject.h"
#include "numpy/arrayscalars.h"
#include "npy_config.h"
#include "npy_pycompat.h"
#include "_datetime.h"
#include "common.h"
#include "descriptor.h"

Defines

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define _MULTIARRAYMODULE
#define NPY_NEXT_ALIGNED_OFFSET(offset, alignment)   (((offset) + (alignment) - 1) & (-(alignment)))
#define PyDictProxy_Check(obj)   (Py_TYPE(obj) == &PyDictProxy_Type)
#define _chk_byteorder(arg)

Functions

static PyArray_Descr_use_inherit (PyArray_Descr *type, PyObject *newobj, int *errflag)
static PyObject * Borrowed_PyMapping_GetItemString (PyObject *o, char *key)
static PyArray_Descr_arraydescr_fromctypes (PyObject *obj)
NPY_NO_EXPORT PyArray_Descr_arraydescr_fromobj (PyObject *obj)
NPY_NO_EXPORT PyObject * array_set_typeDict (PyObject *NPY_UNUSED(ignored), PyObject *args)
static int _check_for_commastring (char *type, Py_ssize_t len)
static int is_datetime_typestr (char *type, Py_ssize_t len)
static PyArray_Descr_convert_from_tuple (PyObject *obj)
static PyArray_Descr_convert_from_array_descr (PyObject *obj, int align)
static PyArray_Descr_convert_from_list (PyObject *obj, int align)
static PyArray_Descr_convert_from_commastring (PyObject *obj, int align)
static int _is_tuple_of_integers (PyObject *obj)
static int validate_object_field_overlap (PyArray_Descr *dtype)
static PyArray_Descr_use_fields_dict (PyObject *obj, int align)
static PyArray_Descr_convert_from_dict (PyObject *obj, int align)
NPY_NO_EXPORT PyArray_DescrPyArray_DescrNewFromType (int type_num)
NPY_NO_EXPORT int PyArray_DescrConverter2 (PyObject *obj, PyArray_Descr **at)
NPY_NO_EXPORT int PyArray_DescrConverter (PyObject *obj, PyArray_Descr **at)
NPY_NO_EXPORT PyArray_DescrPyArray_DescrNew (PyArray_Descr *base)
static void arraydescr_dealloc (PyArray_Descr *self)
static PyObject * arraydescr_subdescr_get (PyArray_Descr *self)
NPY_NO_EXPORT PyObject * arraydescr_protocol_typestr_get (PyArray_Descr *self)
static PyObject * arraydescr_typename_get (PyArray_Descr *self)
static PyObject * arraydescr_base_get (PyArray_Descr *self)
static PyObject * arraydescr_shape_get (PyArray_Descr *self)
NPY_NO_EXPORT PyObject * arraydescr_protocol_descr_get (PyArray_Descr *self)
static PyObject * arraydescr_isbuiltin_get (PyArray_Descr *self)
static int _arraydescr_isnative (PyArray_Descr *self)
static PyObject * arraydescr_isnative_get (PyArray_Descr *self)
static PyObject * arraydescr_isalignedstruct_get (PyArray_Descr *self)
static PyObject * arraydescr_fields_get (PyArray_Descr *self)
static PyObject * arraydescr_metadata_get (PyArray_Descr *self)
static PyObject * arraydescr_hasobject_get (PyArray_Descr *self)
static PyObject * arraydescr_names_get (PyArray_Descr *self)
static int arraydescr_names_set (PyArray_Descr *self, PyObject *val)
static PyObject * arraydescr_new (PyTypeObject *NPY_UNUSED(subtype), PyObject *args, PyObject *kwds)
static PyObject * _get_pickleabletype_from_datetime_metadata (PyArray_Descr *dtype)
static PyObject * arraydescr_reduce (PyArray_Descr *self, PyObject *NPY_UNUSED(args))
static char _descr_find_object (PyArray_Descr *self)
static PyObject * arraydescr_setstate (PyArray_Descr *self, PyObject *args)
NPY_NO_EXPORT int PyArray_DescrAlignConverter (PyObject *obj, PyArray_Descr **at)
NPY_NO_EXPORT int PyArray_DescrAlignConverter2 (PyObject *obj, PyArray_Descr **at)
NPY_NO_EXPORT PyArray_DescrPyArray_DescrNewByteorder (PyArray_Descr *self, char newendian)
static PyObject * arraydescr_newbyteorder (PyArray_Descr *self, PyObject *args)
static int is_dtype_struct_simple_unaligned_layout (PyArray_Descr *dtype)
static PyObject * arraydescr_struct_list_str (PyArray_Descr *dtype)
static PyObject * arraydescr_struct_dict_str (PyArray_Descr *dtype, int includealignedflag)
static PyObject * arraydescr_struct_str (PyArray_Descr *dtype, int includealignflag)
static PyObject * arraydescr_subarray_str (PyArray_Descr *dtype)
static PyObject * arraydescr_str (PyArray_Descr *dtype)
static PyObject * arraydescr_struct_repr (PyArray_Descr *dtype)
NPY_NO_EXPORT PyObject * arraydescr_construction_repr (PyArray_Descr *dtype, int includealignflag, int shortrepr)
static PyObject * arraydescr_repr (PyArray_Descr *dtype)
static PyObject * arraydescr_richcompare (PyArray_Descr *self, PyObject *other, int cmp_op)
static Py_ssize_t descr_length (PyObject *self0)
static PyObject * descr_repeat (PyObject *self, Py_ssize_t length)
static PyObject * descr_subscript (PyArray_Descr *self, PyObject *op)

Variables

static PyObject * typeDict = NULL
static PyMemberDef arraydescr_members []
static PyGetSetDef arraydescr_getsets []
static PyMethodDef arraydescr_methods []
static PySequenceMethods descr_as_sequence
static PyMappingMethods descr_as_mapping
NPY_NO_EXPORT PyTypeObject PyArrayDescr_Type

Define Documentation

#define _chk_byteorder (   arg)
Value:
(arg == '>' || arg == '<' ||        \
                             arg == '|' || arg == '=')
#define NPY_NEXT_ALIGNED_OFFSET (   offset,
  alignment 
)    (((offset) + (alignment) - 1) & (-(alignment)))
offset: A starting offset. alignment: A power-of-two alignment.
This macro returns the smallest value >= 'offset' that is divisible by 'alignment'. Because 'alignment' is a power of two and integers are twos-complement, it is possible to use some simple bit-fiddling to do this.
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define PyDictProxy_Check (   obj)    (Py_TYPE(obj) == &PyDictProxy_Type)

Function Documentation

static PyArray_Descr* _arraydescr_fromctypes ( PyObject *  obj) [static]
Creates a dtype object from ctypes inputs.
Returns a new reference to a dtype object, or NULL if this is not possible. When it returns NULL, it does not set a Python exception.
Understand basic ctypes
Check for ctypes arrays
derived type
Understand ctypes structures --
bit-fields are not supported automatically aligns
This function creates a dtype object when:
  • The object has a "dtype" attribute, and it can be converted to a dtype object.
  • The object is a ctypes type object, including array and structure types.
Returns a new reference to a dtype object, or NULL if this is not possible. When it returns NULL, it does not set a Python exception.
For arbitrary objects that have a "dtype" attribute

References typeDict.

Referenced by PyArray_DescrFromTypeObject().

static int _check_for_commastring ( char *  type,
Py_ssize_t  len 
) [static]
Check for ints at start of string
Check for empty tuple
Check for presence of commas outside square [] brackets. This allows commas inside of [], for parameterized dtypes to use.

Referenced by PyArray_DescrNewFromType().

static PyArray_Descr* _convert_from_array_descr ( PyObject *  obj,
int  align 
) [static]
obj is a list. Each item is a tuple with
(field-name, data-type (either a list or a string), and an optional shape parameter).
field-name can be a string or a 2-tuple data-type can now be a list, string, or 2-tuple

System Message: ERROR/3 (<string>, line 8) Unexpected indentation.

<blockquote> (string, metadata dictionary)</blockquote>

Types with fields need the Python C API for field access
Insert name into nameslist
Process rest
Title can be "meta-data". Only insert it into the fields dictionary if it is a string and if it is not the same as the name.
Structured arrays get a sticky aligned bit
static PyArray_Descr* _convert_from_commastring ( PyObject *  obj,
int  align 
) [static]
comma-separated string this is the format developed by the numarray records module and implemented by the format parser in that module this is an alternative implementation found in the _internal.py file patterned after that one -- the approach is to try to convert to a list (with tuples if any repeat information is present) and then call the _convert_from_list)

TODO: Calling Python from C like this in critical-path code is not
a good idea. This should all be converted to C code.
static PyArray_Descr* _convert_from_dict ( PyObject *  obj,
int  align 
) [static]
Creates a struct dtype object from a Python dictionary.
Types with fields need the Python C API for field access
Use PyMapping_GetItemString to support dictproxy objects as well.
If a property 'aligned' is in the dict, it overrides the align flag to be True if it not already true.
Build item to insert (descr, offset, [title])
Flag whether the fields are specified out of order
If align=True, enforce field alignment
Insert into dictionary
If the fields weren't in order, and there was an OBJECT type, need to verify that no OBJECT types overlap with something else.
Structured arrays get a sticky aligned bit
Override the itemsize if provided
Make sure the itemsize isn't made too small
If align is set, make sure the alignment divides into the size
Set the itemsize
Add the metadata if provided
static PyArray_Descr* _convert_from_list ( PyObject *  obj,
int  align 
) [static]
a list specifying a data-type can just be a list of formats. The names for the fields will default to f0, f1, f2, and so forth.
Types with fields need the Python C API for field access
Ignore any empty string at end which _internal._commastring can produce
End ignore code.
Structured arrays get a sticky aligned bit
static PyArray_Descr* _convert_from_tuple ( PyObject *  obj) [static]
try to interpret next item as a type
We get here if res was NULL but errflag wasn't set --- i.e. the conversion to a data-descr failed in _use_inherit
interpret next item as a typesize
Assume it's a metadata dictionary
interpret next item as shape (if it's a tuple) and reset the type to NPY_VOID with a new fields attribute.
If (type, 1) was given, it is equivalent to type... or (type, ()) was given it is equivalent to type...
validate and set shape
Create a new subarray->shape tuple (it can be an arbitrary sequence of integer like objects, neither of which is safe.
static char _descr_find_object ( PyArray_Descr self) [static]
returns NPY_OBJECT_DTYPE_FLAGS if this data-type has an object portion used when setting the state because hasobject is not stored.
static PyObject* _get_pickleabletype_from_datetime_metadata ( PyArray_Descr dtype) [static]
Return a tuple of (cleaned metadata dictionary, tuple with (str, num))
Create the 2-item tuple to return
Store the metadata dictionary
Convert the datetime metadata into a tuple
Use a 4-tuple that numpy 1.6 knows how to unpickle
static int _is_tuple_of_integers ( PyObject *  obj) [static]
static PyArray_Descr* _use_fields_dict ( PyObject *  obj,
int  align 
) [static]
a dictionary specifying a data-type must have at least two and up to four keys These must all be sequences of the same length.
can also have an additional key called "metadata" which can be any dictionary
"names" --- field names "formats" --- the data-type descriptors for the field.
Optional:
"offsets" --- integers indicating the offset into the record of the start of the field. if not given, then "consecutive offsets" will be assumed and placed in the dictionary.
"titles" --- Allows the use of an additional key for the fields dictionary.(if these are strings or unicode objects) or this can also be meta-data to be passed around with the field description.
Attribute-lookup-based field names merely has to query the fields dictionary of the data-descriptor. Any result present can be used to return the correct field.
So, the notion of what is a name and what is a title is really quite arbitrary.
What does distinguish a title, however, is that if it is not None, it will be placed at the end of the tuple inserted into the fields dictionary.and can therefore be used to carry meta-data around.
If the dictionary does not have "names" and "formats" entries, then it will be checked for conformity and used directly.
static PyArray_Descr * _use_inherit ( PyArray_Descr type,
PyObject *  newobj,
int *  errflag 
) [static]
A tuple type would be either (generic typeobject, typesize) or (fixed-length data-type, shape)
or (inheriting data-type, new-data-type) The new data-type must have the same itemsize as the inheriting data-type unless the latter is 0
Thus (int32, {'real':(int16,0),'imag',(int16,2)})
is one way to specify a descriptor that will give a['real'] and a['imag'] to an int32 array.
leave type reference alone
NPY_NO_EXPORT PyObject* array_set_typeDict ( PyObject *  NPY_UNUSEDignored,
PyObject *  args 
)
Sets the global typeDict object, which is a dictionary mapping dtype names to numpy scalar types.
Decrement old reference (if any)
Create an internal reference to it
static PyObject* arraydescr_base_get ( PyArray_Descr self) [static]
NPY_NO_EXPORT PyObject* arraydescr_construction_repr ( PyArray_Descr dtype,
int  includealignflag,
int  shortrepr 
)
See descriptor.h for documentation
Normalize byteorder to '<' or '>'
Handle booleans, numbers, and custom dtypes
Short repr with endianness, like '<f8'
Longer repr, like 'float64'
All the rest which don't fit in the same pattern
The object reference may be different sizes on different platforms, so it should never include the itemsize here.
static void arraydescr_dealloc ( PyArray_Descr self) [static]
should never be called for builtin-types unless there is a reference-count problem

References arraydescr_protocol_typestr_get(), and PyUString_FromString.

Referenced by arraydescr_struct_repr().

static PyObject* arraydescr_fields_get ( PyArray_Descr self) [static]

Referenced by _arraydescr_isnative().

static PyObject* arraydescr_hasobject_get ( PyArray_Descr self) [static]

Referenced by _arraydescr_isnative().

static PyObject* arraydescr_isalignedstruct_get ( PyArray_Descr self) [static]

Referenced by _arraydescr_isnative().

static PyObject* arraydescr_isbuiltin_get ( PyArray_Descr self) [static]
returns 1 for a builtin type and 2 for a user-defined data-type descriptor return 0 if neither (i.e. it's a copy of one)

References arraydescr_base_get(), arraydescr_protocol_typestr_get(), arraydescr_shape_get(), and arraydescr_typename_get().

static PyObject* arraydescr_isnative_get ( PyArray_Descr self) [static]
return Py_True if this data-type descriptor has native byteorder if no fields are defined
or if all sub-fields have native-byteorder if fields are defined

Referenced by _arraydescr_isnative().

static PyObject* arraydescr_metadata_get ( PyArray_Descr self) [static]

References NPY_TRUE, and PyArray_DescrNew().

Referenced by _arraydescr_isnative().

static PyObject* arraydescr_names_get ( PyArray_Descr self) [static]

Referenced by _arraydescr_isnative().

static int arraydescr_names_set ( PyArray_Descr self,
PyObject *  val 
) [static]
FIXME
This deprecation has been temporarily removed for the NumPy 1.7 release. It should be re-added after the 1.7 branch is done, and a convenience API to replace the typical use-cases for mutable names should be implemented.

if (DEPRECATE("Setting NumPy dtype names is deprecated, the dtype "

<blockquote class="first"> "will become immutable in a future version") < 0) {</blockquote>

System Message: WARNING/2 (<string>, line 10) Block quote ends without a blank line; unexpected unindent.

return -1;

System Message: WARNING/2 (<string>, line 11) Definition list ends without a blank line; unexpected unindent.
}
Make sure all entries are strings
Invalidate cached hash value
Update dictionary keys in fields
Borrowed references to item and new_key
Check for duplicates
Replace names
Replace fields

Referenced by _arraydescr_isnative().

static PyObject* arraydescr_new ( PyTypeObject *  NPY_UNUSEDsubtype,
PyObject *  args,
PyObject *  kwds 
) [static]
Get a new copy of it unless it's already a copy
We need to be sure to make a new copy of the data-type and any underlying dictionary
Make a copy of the metadata before merging with the input metadata so that this data-type descriptor has it's own copy
Save a reference
Decrement the old reference
Update conv->metadata with anything new in metadata keyword, but do not over-write anything already there
Make a copy of the input dictionary

Referenced by _arraydescr_isnative().

static PyObject* arraydescr_newbyteorder ( PyArray_Descr self,
PyObject *  args 
) [static]
get default
static PyObject* arraydescr_reduce ( PyArray_Descr self,
PyObject *  NPY_UNUSEDargs 
) [static]
return a tuple of (callable object, args, state).

TODO: This method needs to change so that unpickling doesn't
use __setstate__. This is required for the dtype to be an immutable object.
version number of this pickle type. Increment if we need to change the format. Be sure to handle the old versions in arraydescr_setstate.
Now return the state which is at least byteorder, subarray, and fields
newobj is a tuple of the Python metadata dictionary and tuple of date_time info (str, num)

<

Use version 3 pickle format
for extended types it also includes elsize and alignment
static PyObject* arraydescr_repr ( PyArray_Descr dtype) [static]
The general dtype repr function.

Referenced by arraydescr_struct_repr().

static PyObject* arraydescr_richcompare ( PyArray_Descr self,
PyObject *  other,
int  cmp_op 
) [static]
static PyObject* arraydescr_setstate ( PyArray_Descr self,
PyObject *  args 
) [static]
state is at least byteorder, subarray, and fields but could include elsize and alignment for EXTENDED arrays
raise an error
If we ever need another pickle format, increment the version number. But we should still be able to handle the old versions.
Invalidate cached hash value
Parse endian
Ensure that subarray[0] is an ArrayDescr and that subarray_shape obtained from subarray[1] is a tuple of integers.
Ensure names are of appropriate string type
We use an integer converted to char for backward compatibility with pickled arrays. Pickled arrays created with previous versions encoded flags as an int even though it actually was a char in the PyArray_Descr structure
We have a borrowed reference to metadata so no need to alter reference count when throwing away Py_None.
static PyObject* arraydescr_shape_get ( PyArray_Descr self) [static]
TODO
self->subarray->shape should always be a tuple, so this check should be unnecessary

Referenced by arraydescr_isbuiltin_get().

static PyObject* arraydescr_str ( PyArray_Descr dtype) [static]
static PyObject* arraydescr_struct_dict_str ( PyArray_Descr dtype,
int  includealignedflag 
) [static]
Returns a string representation of a structured array, in a dict format.
Build up a string to make the dictionary
First, the names
Second, the formats
Check for whether to do titles as well
Third, the offsets
Fourth, the titles
Finally, the itemsize/itemsize and aligned flag
Finally, the itemsize/itemsize
static PyObject* arraydescr_struct_list_str ( PyArray_Descr dtype) [static]
Returns a string representation of a structured array, in a list format.
Build up a string to make the list
Go through all the names
Check for whether to do titles as well
Special case subarray handling here
static PyObject* arraydescr_struct_repr ( PyArray_Descr dtype) [static]
The dtype repr function specifically for structured arrays.
If it's an aligned structure, add the align=True parameter

References arraydescr_dealloc(), arraydescr_repr(), descr_as_mapping, and descr_as_sequence.

static PyObject* arraydescr_struct_str ( PyArray_Descr dtype,
int  includealignflag 
) [static]
Produces a string representation for a structured dtype
The list str representation can't include the 'align=' flag, so if it is requested and the struct has the aligned flag set, we must use the dict str instead.
If the data type has a non-void (subclassed) type, show it
Note: We cannot get the type name from dtype->typeobj->tp_name because its value depends on whether the type is dynamically or statically allocated. Instead use __name__ and __module__. See https://docs.python.org/2/c-api/typeobj.html.
this should never happen since types always have __name__
Note: if modulestr == NULL, the type is unpicklable
static PyObject* arraydescr_subarray_str ( PyArray_Descr dtype) [static]
Produces a string representation for a subarray dtype
static PyObject* arraydescr_subdescr_get ( PyArray_Descr self) [static]
static PyObject* arraydescr_typename_get ( PyArray_Descr self) [static]
NumPy type or subclass
res is derived from typeobj->tp_name with the following rules:

  • if starts with "numpy.", that prefix is removed
  • if ends with "_", that suffix is removed

Referenced by arraydescr_isbuiltin_get().

static PyObject* Borrowed_PyMapping_GetItemString ( PyObject *  o,
char *  key 
) [static]
Returns value of PyMapping_GetItemString but as a borrowed reference instead of a new reference.
static Py_ssize_t descr_length ( PyObject *  self0) [static]

*********** Implement Mapping Protocol ***********************

System Message: WARNING/2 (<string>, line 1)
Title overline too short.

   Implement Mapping Protocol ***************************
 
static PyObject* descr_repeat ( PyObject *  self,
Py_ssize_t  length 
) [static]
static PyObject* descr_subscript ( PyArray_Descr self,
PyObject *  op 
) [static]
static int is_datetime_typestr ( char *  type,
Py_ssize_t  len 
) [static]
static int is_dtype_struct_simple_unaligned_layout ( PyArray_Descr dtype) [static]
Checks whether the structured data type in 'dtype' has a simple layout, where all the fields are in order, and follow each other with no alignment padding.
When this returns true, the dtype can be reconstructed from a list of the field names and dtypes with no additional dtype parameters.
Returns 1 if it has a simple layout, 0 otherwise.
Get some properties from the dtype
Start at offset zero
If this field doesn't follow the pattern, not a simple layout
Get the next offset
If the itemsize doesn't match the final offset, it's not a simple layout.
It's a simple layout, since all the above tests passed
NPY_NO_EXPORT int PyArray_DescrAlignConverter ( PyObject *  obj,
PyArray_Descr **  at 
)
Get type-descriptor from an object forcing alignment if possible

None goes to DEFAULT type.

any object with the .fields attribute and/or .itemsize attribute (if the

.fields attribute does not give the total size -- i.e. a partial record

naming). If itemsize is given it must be >= size computed from fields

The .fields attribute must return a convertible dictionary if present. Result inherits from NPY_VOID.

NPY_NO_EXPORT int PyArray_DescrAlignConverter2 ( PyObject *  obj,
PyArray_Descr **  at 
)
Get type-descriptor from an object forcing alignment if possible
None goes to NULL.
NPY_NO_EXPORT int PyArray_DescrConverter ( PyObject *  obj,
PyArray_Descr **  at 
)
Get typenum from an object -- None goes to NPY_DEFAULT_TYPE

This function takes a Python object representing a type and converts it to a the correct PyArray_Descr * structure to describe the type.

Many objects can be used to represent a data-type which in NumPy is quite a flexible concept.

This is the central code that converts Python objects to Type-descriptor objects that are used throughout numpy.

Returns a new reference in *at, but the returned should not be modified as it may be one of the canonical immutable objects or a reference to the input obj.

System Message: WARNING/2 (<string>, line 11); backlink Inline emphasis start-string without end-string.
default
or a typecode string
Allow unicode format strings: convert to bytes
Check for a string typecode.
Empty string is invalid
check for commas present or first (or second) element a digit
Process the endian character. '|' is replaced by '='
Just an endian character is invalid
Check for datetime format
at has byte order '=' at this point
A typecode like 'd'
A kind + size like 'f8'
Parse the integer, make sure it's the rest of the string
When specifying length of UNICODE the number of characters is given to match the STRING interface. Each character can be more than one byte and itemsize must be the number of bytes.
Support for generic processing c8, i4, f8, etc...
or a tuple
or a list
or a dictionary
Now check to see if the object is registered in typeDict
Check for a deprecated Numeric-style typecode

Referenced by array_nbytes_get(), array_scalar(), and type_tuple_userloop_type_resolver().

NPY_NO_EXPORT int PyArray_DescrConverter2 ( PyObject *  obj,
PyArray_Descr **  at 
)
Get typenum from an object -- None goes to NULL
Array Descr Objects for dynamic types *
There are some statically-defined PyArray_Descr objects corresponding to the basic built-in types. These can and should be DECREF'd and INCREF'd as appropriate, anyway. If a mistake is made in reference counting, deallocation on these builtins will be attempted leading to problems.
This lets us deal with all PyArray_Descr objects using reference counting (regardless of whether they are statically or dynamically allocated).
base cannot be NULL
Don't copy PyObject_HEAD part
The c_metadata has a by-value ownership model, need to clone it (basically a deep copy, but the auxdata clone function has some flexibility still) so the new PyArray_Descr object owns a copy of the data. Having both 'base' and 'newdescr' point to the same auxdata pointer would cause a double-free of memory.

Referenced by arraydescr_metadata_get().

returns a copy of the PyArray_Descr structure with the byteorder

altered: no arguments: The byteorder is swapped (in all subfields as well) single argument: The byteorder is forced to the given state (in all subfields as well)

Valid states: ('big', '>') or ('little' or '<') ('native', or '=')

If a descr structure with | is encountered it's own byte-order is not changed but any fields are:

Deep bytorder change of a data-type descriptor * Leaves reference count of self unchanged --- does not DECREF self *

swap byteorder
make new dictionary with replaced PyArray_Descr Objects
static int validate_object_field_overlap ( PyArray_Descr dtype) [static]
Validates that any field of the structured array 'dtype' which has the NPY_ITEM_HASOBJECT flag set does not overlap with another field.
This algorithm is worst case O(n^2). It could be done with a sort and sweep algorithm, but the structured dtype representation is rather ugly right now, so writing something better can wait until that representation is made sane.
Returns 0 on success, -1 if an exception is raised.
Get some properties from the dtype
If this field has objects, check for overlaps
Raise an exception if it overlaps
It passed all the overlap tests

Variable Documentation

PyGetSetDef arraydescr_getsets[] [static]
PyMemberDef arraydescr_members[] [static]
Initial value:
 {
    {"type",
        T_OBJECT, offsetof(PyArray_Descr, typeobj), READONLY, NULL},
    {"kind",
        T_CHAR, offsetof(PyArray_Descr, kind), READONLY, NULL},
    {"char",
        T_CHAR, offsetof(PyArray_Descr, type), READONLY, NULL},
    {"num",
        T_INT, offsetof(PyArray_Descr, type_num), READONLY, NULL},
    {"byteorder",
        T_CHAR, offsetof(PyArray_Descr, byteorder), READONLY, NULL},
    {"itemsize",
        T_INT, offsetof(PyArray_Descr, elsize), READONLY, NULL},
    {"alignment",
        T_INT, offsetof(PyArray_Descr, alignment), READONLY, NULL},
    {"flags",
        T_BYTE, offsetof(PyArray_Descr, flags), READONLY, NULL},
    {NULL, 0, 0, 0, NULL},
}
we need to be careful about setting attributes because these objects are pointed to by arrays that depend on them for interpreting data. Currently no attributes of data-type objects can be set directly except names.
PyMethodDef arraydescr_methods[] [static]
Initial value:
 {
    
    {"__reduce__",
        (PyCFunction)arraydescr_reduce,
        METH_VARARGS, NULL},
    {"__setstate__",
        (PyCFunction)arraydescr_setstate,
        METH_VARARGS, NULL},
    {"newbyteorder",
        (PyCFunction)arraydescr_newbyteorder,
        METH_VARARGS, NULL},
    {NULL, NULL, 0, NULL}           
}
PyMappingMethods descr_as_mapping [static]
Initial value:
 {
    descr_length,                                
    (binaryfunc)descr_subscript,                 
    (objobjargproc)NULL,                         
}

Referenced by arraydescr_struct_repr().

PySequenceMethods descr_as_sequence [static]
Initial value:
 {
    descr_length,
    (binaryfunc)NULL,
    descr_repeat,
    NULL, NULL,
    NULL,                                        
    NULL,                                        
    0,                                           
    0,                                           
    0,                                           
}

Referenced by arraydescr_struct_repr().

************ End of Mapping Protocol *************************

Referenced by _fill(), and array_reduce().

PyObject* typeDict = NULL [static]
Must be explicitly loaded

Referenced by _arraydescr_fromobj().