Skip to content

Commit

Permalink
Merge pull request #23 from yuyichao/master
Browse files Browse the repository at this point in the history
remove dtype hash hack since it is fixed in pypy
  • Loading branch information
inducer committed Sep 22, 2014
2 parents 2293b43 + d1623ee commit 5d54e1b
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,7 @@

# {{{ registry

try:
hash(np.dtype([('s1', np.int8), ('s2', np.int8)]))
DTypeDict = dict
dtype_to_key = lambda t: t
dtype_hashable = True
except:
import json as _json
dtype_hashable = False
dtype_to_key = lambda t: _json.dumps(t.descr, separators=(',', ':'))
class DTypeDict:
def __init__(self):
self.__dict = {}
self.__type_dict = {}
def __delitem__(self, key):
try:
del self.__dict[key]
except TypeError:
del self.__type_dict[dtype_to_key(key)]
def __setitem__(self, key, val):
try:
self.__dict[key] = val
except TypeError:
self.__type_dict[dtype_to_key(key)] = val
def __getitem__(self, key):
try:
return self.__dict[key]
except TypeError:
return self.__type_dict[dtype_to_key(key)]
def __contains__(self, key):
try:
return key in self.__dict
except TypeError:
return dtype_to_key(key) in self.__type_dict

DTYPE_TO_NAME = DTypeDict()
DTYPE_TO_NAME = {}
NAME_TO_DTYPE = {}


Expand Down

0 comments on commit 5d54e1b

Please sign in to comment.