Performance Improvement - Replace classes used for data storage by named tuples
fabanc opened this issue · comments
The following class are used only to store data. The performance and the memory footprint should be better if those classes are replaced by named tuples.
class Vertex:
X = 0.0
Y = 0.0
def __init__(self,x,y):
self.X = x
self.Y = y
class Edge:
start = -1
end = -1
is_primary = False
is_linear = False
cell = -1
twin = -1
def __init__(self, start, end, cell, twin):
self.start = start
self.end = end
self.cell = cell
self.twin = twin
class Cell:
cell_identifier = -1
site = -1
contains_point = False
contains_segment = False
is_open = False
vertices = []
edges = []
source_category = None
def __init__(self, cell_identifier, site, vertices, edges, source_category):
self.cell_identifier = cell_identifier
self.site = site
self.source_category = source_category
self.vertices = vertices
self.edges = edges
if len(self.vertices) > 0:
self.vertices.append(self.vertices[0])