Fix performance of c_array in python core.py (#2786)
This commit is contained in:
parent
9fbeeea46e
commit
602b34ab91
@ -159,6 +159,8 @@ def c_str(string):
|
|||||||
|
|
||||||
def c_array(ctype, values):
|
def c_array(ctype, values):
|
||||||
"""Convert a python string to c array."""
|
"""Convert a python string to c array."""
|
||||||
|
if isinstance(values, np.ndarray) and values.dtype.itemsize == ctypes.sizeof(ctype):
|
||||||
|
return (ctype * len(values)).from_buffer_copy(values)
|
||||||
return (ctype * len(values))(*values)
|
return (ctype * len(values))(*values)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user