Merged revisions 62338 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62338 | thomas.heller | 2008-04-14 18:10:07 +0200 (Mo, 14 Apr 2008) | 3 lines
Issue #2616: Implement ctypes.pointer() and ctypes.POINTER() in C for
better performance.
........
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index b6e598f..abda3df 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -239,27 +239,7 @@
class c_bool(_SimpleCData):
_type_ = "?"
-# This cache maps types to pointers to them.
-_pointer_type_cache = {}
-
-def POINTER(cls):
- try:
- return _pointer_type_cache[cls]
- except KeyError:
- pass
- if type(cls) is str:
- klass = type(_Pointer)("LP_%s" % cls,
- (_Pointer,),
- {})
- _pointer_type_cache[id(klass)] = klass
- return klass
- else:
- name = "LP_%s" % cls.__name__
- klass = type(_Pointer)(name,
- (_Pointer,),
- {'_type_': cls})
- _pointer_type_cache[cls] = klass
- return klass
+from _ctypes import POINTER, pointer, _pointer_type_cache
try:
from _ctypes import set_conversion_mode
@@ -309,10 +289,6 @@
_pointer_type_cache[cls] = pointer
del _pointer_type_cache[id(pointer)]
-
-def pointer(inst):
- return POINTER(type(inst))(inst)
-
# XXX Deprecated
def ARRAY(typ, len):
return typ * len