diff options
author | Thomas Heller <theller@ctypes.org> | 2008-04-14 16:17:33 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2008-04-14 16:17:33 (GMT) |
commit | 3071f8191bec3fee4a9fc5f8ec30c52dc8cd3ac2 (patch) | |
tree | 79e832cd57ef983bf8a43061faa28528ee1894e7 /Lib | |
parent | c2ea8c6c3ace398ed757f104d59b32ecad046281 (diff) | |
download | cpython-3071f8191bec3fee4a9fc5f8ec30c52dc8cd3ac2.zip cpython-3071f8191bec3fee4a9fc5f8ec30c52dc8cd3ac2.tar.gz cpython-3071f8191bec3fee4a9fc5f8ec30c52dc8cd3ac2.tar.bz2 |
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.
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/__init__.py | 26 |
1 files changed, 1 insertions, 25 deletions
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 @@ _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 @@ -309,10 +289,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 |