summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-04-14 16:10:07 (GMT)
committerThomas Heller <theller@ctypes.org>2008-04-14 16:10:07 (GMT)
commit046e6a43ff64885d9f5cdaac13a2b9f6e0ee8c84 (patch)
tree5acb0a36e8bcadbf5bca7c981c911178af2acbe6 /Lib/ctypes
parentda950eb01c1191e6ccdd02ca009fca7ead2b3066 (diff)
downloadcpython-046e6a43ff64885d9f5cdaac13a2b9f6e0ee8c84.zip
cpython-046e6a43ff64885d9f5cdaac13a2b9f6e0ee8c84.tar.gz
cpython-046e6a43ff64885d9f5cdaac13a2b9f6e0ee8c84.tar.bz2
Issue #2616: Implement ctypes.pointer() and ctypes.POINTER() in C for
better performance.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/__init__.py26
1 files changed, 1 insertions, 25 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 7cacdd2..41d39dc 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -242,27 +242,7 @@ _check_size(c_void_p)
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
@@ -312,10 +292,6 @@ def SetPointerType(pointer, cls):
_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