Skip to content

Commit 1bf3c4b

Browse files
committed
Merge pull request #166 from shoyer/dont-use-__slots__
Revert using __slots__ for Mapping subclasses in xray.utils
2 parents 4fce6d2 + 3d6eab5 commit 1bf3c4b

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

xray/utils.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pandas as pd
77

88
import xray
9-
from .pycompat import basestring, iteritems, PY3
9+
from .pycompat import basestring, iteritems
1010

1111

1212
def alias_warning(old_name, new_name, stacklevel=2):
@@ -218,8 +218,6 @@ class Frozen(Mapping):
218218
immutable. If you really want to modify the mapping, the mutable version is
219219
saved under the `mapping` attribute.
220220
"""
221-
__slots__ = ['mapping']
222-
223221
def __init__(self, mapping):
224222
self.mapping = mapping
225223

@@ -238,11 +236,6 @@ def __contains__(self, key):
238236
def __repr__(self):
239237
return '%s(%r)' % (type(self).__name__, self.mapping)
240238

241-
if not PY3:
242-
def __getstate__(self):
243-
return self.__dict__
244-
245-
246239
def FrozenOrderedDict(*args, **kwargs):
247240
return Frozen(OrderedDict(*args, **kwargs))
248241

@@ -252,8 +245,6 @@ class SortedKeysDict(MutableMapping):
252245
items in sorted order by key but is otherwise equivalent to the underlying
253246
mapping.
254247
"""
255-
__slots__ = ['mapping']
256-
257248
def __init__(self, mapping=None):
258249
self.mapping = {} if mapping is None else mapping
259250

@@ -281,19 +272,13 @@ def __repr__(self):
281272
def copy(self):
282273
return type(self)(self.mapping.copy())
283274

284-
if not PY3:
285-
def __getstate__(self):
286-
return self.__dict__
287-
288275

289276
class ChainMap(MutableMapping):
290277
"""Partial backport of collections.ChainMap from Python>=3.3
291278
292279
Don't return this from any public APIs, since some of the public methods
293280
for a MutableMapping are missing (they will raise a NotImplementedError)
294281
"""
295-
__slots__ = ['maps']
296-
297282
def __init__(self, *maps):
298283
self.maps = maps
299284

@@ -317,10 +302,6 @@ def __iter__(self):
317302
def __len__(self):
318303
raise NotImplementedError
319304

320-
if not PY3:
321-
def __getstate__(self):
322-
return self.__dict__
323-
324305

325306
class NDArrayMixin(object):
326307
"""Mixin class for making wrappers of N-dimensional arrays that conform to

0 commit comments

Comments
 (0)