File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,19 @@ class c_bool(_SimpleCData):
268
268
from _ctypes import POINTER , pointer , _pointer_type_cache
269
269
270
270
def 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
+ """
271
284
if cls is None :
272
285
return c_void_p
273
286
try :
@@ -280,9 +293,16 @@ def POINTER(cls):
280
293
return type (f'LP_{ cls } ' , (_Pointer ,), {})
281
294
return type (f'LP_{ cls .__name__ } ' , (_Pointer ,), {'_type_' : cls })
282
295
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 )
286
306
287
307
class c_wchar_p (_SimpleCData ):
288
308
_type_ = "Z"
You can’t perform that action at this time.
0 commit comments