MCPcopy Create free account
hub / github.com/dmlc/treelite / c_array

Function c_array

python/treelite/util.py:56–66  ·  view source on GitHub ↗

Convert a Python byte array to C array WARNING ------- DO NOT USE THIS FUNCTION if performance is critical. Instead, use np.array(*) with dtype option to explicitly convert type and then use ndarray.ctypes.data_as(*) to expose underlying buffer as C pointer.

(ctype, values)

Source from the content-addressed store, hash-verified

54
55
56def c_array(ctype, values):
57 """
58 Convert a Python byte array to C array
59
60 WARNING
61 -------
62 DO NOT USE THIS FUNCTION if performance is critical. Instead, use np.array(*)
63 with dtype option to explicitly convert type and then use
64 ndarray.ctypes.data_as(*) to expose underlying buffer as C pointer.
65 """
66 return (ctype * len(values))(*values)
67
68
69_T = TypeVar("_T")

Callers 7

treelite_deserializeFunction · 0.90
categorical_testMethod · 0.85
leafMethod · 0.85
concatenateMethod · 0.85
as_c_arrayMethod · 0.85
import_modelFunction · 0.85

Calls

no outgoing calls

Tested by 1

treelite_deserializeFunction · 0.72