diff --git a/pyopencl/array.py b/pyopencl/array.py index 01eaf395bd3d82a9d4e611d89d88f5a69f04ecd0..b43756f9a30d7612a3719a59d9c7937f1208a752 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -38,7 +38,6 @@ from pyopencl.compyte.array import ( c_contiguous_strides as _c_contiguous_strides, ArrayFlags as _ArrayFlags, get_common_dtype as _get_common_dtype_base) -from pyopencl.compyte.dtypes import DTypeDict as _DTypeDict from pyopencl.characterize import has_double_support @@ -70,7 +69,7 @@ def _create_vector_types(): from pyopencl.tools import get_or_register_dtype vec.types = {} - vec.type_to_scalar_and_count = _DTypeDict() + vec.type_to_scalar_and_count = {} counts = [2, 3, 4, 8, 16] diff --git a/pyopencl/tools.py b/pyopencl/tools.py index bc760a9421247dd428d83a130dcc0078c857c934..92bf3a80a6c001d2e1e8b2ace3e80652591e8af6 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -37,9 +37,7 @@ import re from pyopencl.compyte.dtypes import ( # noqa get_or_register_dtype, TypeNameNotKnown, - register_dtype, dtype_to_ctype, - dtype_hashable as _dtype_hashable, - dtype_to_key as _dtype_to_key) + register_dtype, dtype_to_ctype) def _register_types(): @@ -515,16 +513,8 @@ class _CDeclList: return result -if _dtype_hashable: - _memoize_match_dtype_to_c_struct = memoize -else: - import json as _json - _memoize_match_dtype_to_c_struct = memoize( - key=lambda device, name, dtype, context=None: - (device, name, _dtype_to_key(dtype), context)) - -@_memoize_match_dtype_to_c_struct +@memoize def match_dtype_to_c_struct(device, name, dtype, context=None): """Return a tuple `(dtype, c_decl)` such that the C struct declaration in `c_decl` and the structure :class:`numpy.dtype` instance `dtype` @@ -672,15 +662,8 @@ def match_dtype_to_c_struct(device, name, dtype, context=None): return dtype, c_decl -if _dtype_hashable: - _memoize_dtype_to_c_struct = memoize -else: - import json as _json # noqa - _memoize_dtype_to_c_struct = memoize( - key=lambda device, dtype: (device, _dtype_to_key(dtype))) - -@_memoize_dtype_to_c_struct +@memoize def dtype_to_c_struct(device, dtype): matched_dtype, c_decl = match_dtype_to_c_struct( device, dtype_to_ctype(dtype), dtype)