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]
1924
2025
21- class Base (ABC ):
26+ # import abc
27+ # ABC = abc.ABCMeta('ABC', (object,), {'__slots__': ()})
28+
29+
30+ class Base (object ):
2231 """Abstract base class for all COMPAS objects.
2332
2433 Attributes
@@ -73,24 +82,22 @@ def dtype(self):
7382 """
7483 return "{}/{}" .format ("." .join (self .__class__ .__module__ .split ("." )[:2 ]), self .__class__ .__name__ )
7584
76- @abc . abstractproperty
85+ @property
7786 def data (self ):
7887 """dict :
7988 The representation of the object as native Python data.
8089 The structure uf the data is described by the data schema.
8190 """
82- pass
91+ raise NotImplementedError
8392
8493 @data .setter
8594 def data (self , data ):
8695 pass
8796
88- @abstractclassmethod
8997 def from_data (cls , data ):
9098 """Construct an object of this type from the provided data."""
91- pass
99+ raise NotImplementedError
92100
93- @abc .abstractmethod
94101 def to_data (self ):
95102 """Convert an object to its native data representation.
96103
@@ -99,9 +106,8 @@ def to_data(self):
99106 dict
100107 The data representation of the object as described by the schema.
101108 """
102- pass
109+ raise NotImplementedError
103110
104- @abstractclassmethod
105111 def from_json (cls , filepath ):
106112 """Construct an object from serialised data contained in a JSON file.
107113
@@ -110,9 +116,8 @@ def from_json(cls, filepath):
110116 filepath: str
111117 The path to the file for serialisation.
112118 """
113- pass
119+ raise NotImplementedError
114120
115- @abc .abstractmethod
116121 def to_json (self , filepath ):
117122 """Serialize the data representation of an object to a JSON file.
118123
@@ -121,7 +126,7 @@ def to_json(self, filepath):
121126 filepath: str
122127 The path to the file containing the data.
123128 """
124- pass
129+ raise NotImplementedError
125130
126131 def __getstate__ (self ):
127132 """Return the object data for state state serialisation with older pickle protocols."""
0 commit comments