1+ """
2+ If you ever feel tempted to use ABCMeta in your code: don't, just DON'T.
3+ Assigning __metaclass__ = ABCMeta to a class causes a severe memory leak/performance
4+ degradation on IronPython 2.7.
5+
6+ See these issues for more details:
7+ - https://github.com/compas-dev/compas/issues/562
8+ - https://github.com/compas-dev/compas/issues/649
9+ """
110from __future__ import print_function
211from __future__ import absolute_import
312from __future__ import division
413
5- import abc
614import json
715from uuid import uuid4
816
917from compas .utilities import DataEncoder
1018from compas .utilities import DataDecoder
11- from compas .utilities import abstractclassmethod
12-
13- ABC = abc .ABCMeta ('ABC' , (object ,), {'__slots__' : ()})
1419
1520
1621__all__ = [
1722 'Base' ,
1823]
24+ import abc
25+ ABC = abc .ABCMeta ('ABC' , (object ,), {'__slots__' : ()})
1926
2027
2128class Base (ABC ):
@@ -73,24 +80,22 @@ def dtype(self):
7380 """
7481 return "{}/{}" .format ("." .join (self .__class__ .__module__ .split ("." )[:2 ]), self .__class__ .__name__ )
7582
76- @abc . abstractproperty
83+ @property
7784 def data (self ):
7885 """dict :
7986 The representation of the object as native Python data.
8087 The structure uf the data is described by the data schema.
8188 """
82- pass
89+ raise NotImplementedError
8390
8491 @data .setter
8592 def data (self , data ):
8693 pass
8794
88- @abstractclassmethod
8995 def from_data (cls , data ):
9096 """Construct an object of this type from the provided data."""
91- pass
97+ raise NotImplementedError
9298
93- @abc .abstractmethod
9499 def to_data (self ):
95100 """Convert an object to its native data representation.
96101
@@ -99,9 +104,8 @@ def to_data(self):
99104 dict
100105 The data representation of the object as described by the schema.
101106 """
102- pass
107+ raise NotImplementedError
103108
104- @abstractclassmethod
105109 def from_json (cls , filepath ):
106110 """Construct an object from serialised data contained in a JSON file.
107111
@@ -110,9 +114,8 @@ def from_json(cls, filepath):
110114 filepath: str
111115 The path to the file for serialisation.
112116 """
113- pass
117+ raise NotImplementedError
114118
115- @abc .abstractmethod
116119 def to_json (self , filepath ):
117120 """Serialize the data representation of an object to a JSON file.
118121
@@ -121,7 +124,7 @@ def to_json(self, filepath):
121124 filepath: str
122125 The path to the file containing the data.
123126 """
124- pass
127+ raise NotImplementedError
125128
126129 def __getstate__ (self ):
127130 """Return the object data for state state serialisation with older pickle protocols."""
0 commit comments