File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,6 +268,19 @@ class c_bool(_SimpleCData):
268268from _ctypes import POINTER , pointer , _pointer_type_cache
269269
270270def POINTER (cls ):
271+ """
272+ Create and return a new ctypes pointer type.
273+
274+ cls
275+ A ctypes type.
276+
277+ Pointer types are cached and reused internally,
278+ so calling this function repeatedly is cheap.
279+
280+ Pointer types for incomplete types are not cached,
281+ so calling this function repeatedly will give
282+ different types.
283+ """
271284 if cls is None :
272285 return c_void_p
273286 try :
@@ -280,9 +293,16 @@ def POINTER(cls):
280293 return type (f'LP_{ cls } ' , (_Pointer ,), {})
281294 return type (f'LP_{ cls .__name__ } ' , (_Pointer ,), {'_type_' : cls })
282295
283- def pointer (arg ):
284- typ = POINTER (type (arg ))
285- return typ (arg )
296+ def pointer (obj ):
297+ """
298+ Create a new pointer instance, pointing to 'obj'.
299+
300+ The returned object is of the type POINTER(type(obj)). Note that if you
301+ just want to pass a pointer to an object to a foreign function call, you
302+ should use byref(obj) which is much faster.
303+ """
304+ typ = POINTER (type (obj ))
305+ return typ (obj )
286306
287307class c_wchar_p (_SimpleCData ):
288308 _type_ = "Z"
You can’t perform that action at this time.
0 commit comments