numpy 1.22.4 Pypi GitHub Homepage
Other Docs

In an ideal world, we could achieve this through the PEP3118 buffer protocol, something like:

def dtype_from_ctypes_type(t):
    # needed to ensure that the shape of `t` is within memoryview.format
    class DummyStruct(ctypes.Structure):
        _fields_ = [('a', t)]

    # empty to avoid memory allocation
    ctype_0 = (DummyStruct * 0)()
    mv = memoryview(ctype_0)

    # convert the struct, and slice back out the field
    return _dtype_from_pep3118(mv.format)['a']

Unfortunately, this fails because:

Conversion from ctypes to dtype.

Conversion from ctypes to dtype.

In an ideal world, we could achieve this through the PEP3118 buffer protocol, something like:

def dtype_from_ctypes_type(t):
    # needed to ensure that the shape of `t` is within memoryview.format
    class DummyStruct(ctypes.Structure):
        _fields_ = [('a', t)]

    # empty to avoid memory allocation
    ctype_0 = (DummyStruct * 0)()
    mv = memoryview(ctype_0)

    # convert the struct, and slice back out the field
    return _dtype_from_pep3118(mv.format)['a']

Unfortunately, this fails because:

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/core/_dtype_ctypes.py#0
type: <class 'module'>
Commit: