try to max out mpl wrapper performance

This commit is contained in:
Laura Klünder 2017-11-18 22:53:17 +01:00
parent b700ccd46c
commit a679a81432

View file

@ -18,8 +18,10 @@ class MplPathProxy(ABC):
class MplMultipolygonPath(MplPathProxy): class MplMultipolygonPath(MplPathProxy):
__slots__ = ('polygons')
def __init__(self, polygon): def __init__(self, polygon):
self.polygons = [MplPolygonPath(polygon) for polygon in assert_multipolygon(polygon)] self.polygons = tuple(MplPolygonPath(polygon) for polygon in assert_multipolygon(polygon))
@property @property
def exteriors(self): def exteriors(self):
@ -46,6 +48,8 @@ class MplMultipolygonPath(MplPathProxy):
class MplPolygonPath(MplPathProxy): class MplPolygonPath(MplPathProxy):
__slots__ = ('exterior', 'interiors')
def __init__(self, polygon): def __init__(self, polygon):
self.exterior = linearring_to_mpl_path(polygon.exterior) self.exterior = linearring_to_mpl_path(polygon.exterior)
self.interiors = [linearring_to_mpl_path(interior) for interior in polygon.interiors] self.interiors = [linearring_to_mpl_path(interior) for interior in polygon.interiors]