Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP simulation time speedup #60

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

WIP simulation time speedup #60

wants to merge 1 commit into from

Conversation

RobinGeens
Copy link
Contributor

There's a lot of low-hanging fruit in the optimization of the code.

Most of the simulation time is spent on dict-related operations, __hash__ and __eq__ in particular. This PR includes the following optimalizations:

  • For layer dimensions: compute the hash at instantiation and replace the dynamic hash function with a reference to the static hash
  • For layer dimensions: simplify __eq__ to comparing hashes
  • Replace dict with manually added default values for expected lookups with defaultdict

@RobinGeens RobinGeens mentioned this pull request Jun 2, 2024

@property
def name(self):
"""Protect the class variable from reassignment (as this would invalidate the stored hash value)"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frozen dataclasses might be interesting for this.

https://docs.python.org/3/library/dataclasses.html#frozen-instances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants