Skip to content
Snippets Groups Projects
Commit b874af0a authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Add __slots__ to some classes

parent ea99fc59
No related branches found
No related tags found
1 merge request!442Add __slots__ to some classes
Pipeline #132084 passed
...@@ -454,9 +454,10 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -454,9 +454,10 @@ class AbstractOperation(Operation, AbstractGraphComponent):
behavior. behavior.
""" """
__slots__ = ("_input_ports", "_output_ports", "_execution_time")
_input_ports: List[InputPort] _input_ports: List[InputPort]
_output_ports: List[OutputPort] _output_ports: List[OutputPort]
_execution_time: Union[int, None] = None _execution_time: Optional[int]
def __init__( def __init__(
self, self,
......
...@@ -130,6 +130,7 @@ class AbstractPort(Port): ...@@ -130,6 +130,7 @@ class AbstractPort(Port):
behavior. behavior.
""" """
__slots__ = ("_operation", "_index", "_latency_offset")
_operation: "Operation" _operation: "Operation"
_index: int _index: int
_latency_offset: Optional[int] _latency_offset: Optional[int]
...@@ -276,6 +277,7 @@ class InputPort(AbstractPort): ...@@ -276,6 +277,7 @@ class InputPort(AbstractPort):
May have one or zero signals connected to it. May have one or zero signals connected to it.
""" """
__slots__ = ("_source_signal",)
_source_signal: Optional[Signal] _source_signal: Optional[Signal]
def __init__(self, operation: "Operation", index: int): def __init__(self, operation: "Operation", index: int):
...@@ -372,6 +374,7 @@ class OutputPort(AbstractPort, SignalSourceProvider): ...@@ -372,6 +374,7 @@ class OutputPort(AbstractPort, SignalSourceProvider):
May have zero or more signals connected to it. May have zero or more signals connected to it.
""" """
__slots__ = ("_destination_signals",)
_destination_signals: List[Signal] _destination_signals: List[Signal]
def __init__(self, operation: "Operation", index: int): def __init__(self, operation: "Operation", index: int):
......
...@@ -24,6 +24,11 @@ class Process: ...@@ -24,6 +24,11 @@ class Process:
The name of the process. The name of the process.
""" """
__slots__ = ("_start_time", "_execution_time", "_name")
_start_time: int
_execution_time: int
_name: str
def __init__(self, start_time: int, execution_time: int, name: str = ""): def __init__(self, start_time: int, execution_time: int, name: str = ""):
self._start_time = start_time self._start_time = start_time
self._execution_time = execution_time self._execution_time = execution_time
...@@ -82,6 +87,9 @@ class OperatorProcess(Process): ...@@ -82,6 +87,9 @@ class OperatorProcess(Process):
The name of the process. The name of the process.
""" """
__slots__ = ("_operation",)
_operation: Operation
def __init__( def __init__(
self, self,
start_time: int, start_time: int,
...@@ -131,6 +139,9 @@ class MemoryProcess(Process): ...@@ -131,6 +139,9 @@ class MemoryProcess(Process):
Name of the process. Name of the process.
""" """
__slots__ = ("_life_times",)
_life_times: List[int]
def __init__( def __init__(
self, self,
write_time: int, write_time: int,
...@@ -274,6 +285,11 @@ class MemoryVariable(MemoryProcess): ...@@ -274,6 +285,11 @@ class MemoryVariable(MemoryProcess):
The name of the process. The name of the process.
""" """
__slots__ = ("_reads", "_read_ports", "_write_port")
_reads: Dict[InputPort, int]
_read_ports: List[InputPort]
_write_port: OutputPort
def __init__( def __init__(
self, self,
write_time: int, write_time: int,
...@@ -359,6 +375,11 @@ class PlainMemoryVariable(MemoryProcess): ...@@ -359,6 +375,11 @@ class PlainMemoryVariable(MemoryProcess):
The name of the process. The name of the process.
""" """
__slots__ = ("_reads", "_read_ports", "_write_port")
_reads: Dict[int, int]
_read_ports: List[int]
_write_port: OutputPort
def __init__( def __init__(
self, self,
write_time: int, write_time: int,
......
...@@ -449,6 +449,11 @@ class ProcessCollection: ...@@ -449,6 +449,11 @@ class ProcessCollection:
.. math:: t = t \bmod T_{\textrm{schedule}}. .. math:: t = t \bmod T_{\textrm{schedule}}.
""" """
__slots__ = ("_collection", "_schedule_time", "_cyclic")
_collection: List[Process]
_schedule_time: int
_cyclic: bool
def __init__( def __init__(
self, self,
collection: Iterable[Process], collection: Iterable[Process],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment