Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ctypes.pointer, ctypes.POINTER, and ctypes.byref?

Tags:

python

ctypes

In ctypes, what is the difference between pointer and byref? They both seem like a way to pass a pointer to a function, for example as an output parameter.

like image 410
joeforker Avatar asked Sep 05 '12 12:09

joeforker


People also ask

What is Ctypes Byref?

ctypes exports the byref() function which is used to pass parameters by reference.


1 Answers

Functionally, they are equivalent.

However, the python docs do point out that

pointer does a lot more work since it constructs a real pointer object, so it is faster to use byref if you don't need the pointer object in Python itself.
like image 170
jam Avatar answered Sep 21 '22 15:09

jam