- Notifications
You must be signed in to change notification settings - Fork752
Closed
Description
Hello,
I try to use the following snippetfrom this page to turn abyte[]
into a numpy array:
fromctypesimportstring_atclr.AddReference("System.Runtime.InteropServices")fromSystem.Runtime.InteropServicesimportGCHandle,GCHandleTypehandler=GCHandle.Alloc(CSArray,GCHandleType.Pinned)try:pointer=handler.AddrOfPinnedObject().ToInt32()dest=np.fromstring(string_at(pointer,len(CSArray)))finally:ifhandler.IsAllocated:handler.Free()
On this line:
handler=GCHandle.Alloc(CSArray,GCHandleType.Pinned)
I get the following error:TypeError: No method matches given arguments
Executing this code:
handler=GCHandle.Alloc(CSArray)
brings no error, so I assume that the issue must be fromGCHandleType.Pinned
.
I'm a bit troubled by:
print(type(GCHandleType.Pinned))>>>intprint(GCHandleType.Pinned)>>>3
Is it normal thatenum
are modeled byint
?
Anyway, I can't get to have my code working...
Metadata
Metadata
Assignees
Labels
No labels