cpyquickhelper.examplesΒΆ
There is no particular purpose to this examples except testing some assumptions. The first class introduces a C container which holds a void pointer.
cpyquickhelper.examples.custom_container_python.ContainerType
(self, value)
Type enumeration, similar to dtype.
Members:
VOID : untyped pointer
BYTE : byte pointer
FLOAT : float pointer
DOUBLE : double pointer
INT64 : int64 pointer
cpyquickhelper.examples.custom_container_python.PyCContainer
Custom container, may contain almost everything.
The following example is a way to get the sequence of bytes for a sequence of doubles.
<<<
import numpy
from cpyquickhelper.examples.custom_container_python import PyCContainer
arr = numpy.array([0, 2, 8, 8e-2, 1], dtype=numpy.float32)
cc = PyCContainer(arr)
print(cc.dtype)
print(cc.size)
content = [cc[i] for i in range(cc.size)]
print(content)
>>>
ContainerType.FLOAT
20
[0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 65, 10, 215, 163, 61, 0, 0, 128, 63]