numpy  2.0.0
src/multiarray/descriptor.h File Reference

Go to the source code of this file.

Functions

NPY_NO_EXPORT PyObject * arraydescr_protocol_typestr_get (PyArray_Descr *)
NPY_NO_EXPORT PyObject * arraydescr_protocol_descr_get (PyArray_Descr *self)
NPY_NO_EXPORT PyObject * array_set_typeDict (PyObject *NPY_UNUSED(ignored), PyObject *args)
NPY_NO_EXPORT PyArray_Descr_arraydescr_fromobj (PyObject *obj)
NPY_NO_EXPORT PyObject * arraydescr_construction_repr (PyArray_Descr *dtype, int includealignflag, int shortrepr)

Variables

NPY_NO_EXPORT char * _datetime_strings []

Function Documentation

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().

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
NPY_NO_EXPORT PyObject* arraydescr_construction_repr ( PyArray_Descr dtype,
int  includealignflag,
int  shortrepr 
)
Creates a string repr of the dtype, excluding the 'dtype()' part surrounding the object. This object may be a string, a list, or a dict depending on the nature of the dtype. This is the object passed as the first parameter to the dtype constructor, and if no additional constructor parameters are given, will reproduce the exact memory layout.
If 'shortrepr' is non-zero, this creates a shorter repr using 'kind' and 'itemsize', instead of the longer type name.
If 'includealignflag' is true, this includes the 'align=True' parameter inside the struct dtype construction dict when needed. Use this flag if you want a proper repr string without the 'dtype()' part around it.
If 'includealignflag' is false, this does not preserve the 'align=True' parameter or sticky NPY_ALIGNED_STRUCT flag for struct arrays like the regular repr does, because the 'align' flag is not part of first dtype constructor parameter. This mode is intended for a full 'repr', where the 'align=True' is provided as the second parameter.
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.
get default

Variable Documentation

Exported as DATETIMEUNITS in multiarraymodule.c