Skip to content

Issue #0: Remove slow hash.#169

Closed
Mark2000 wants to merge 1 commit intodevelopfrom
Mark2000-patch-1
Closed

Issue #0: Remove slow hash.#169
Mark2000 wants to merge 1 commit intodevelopfrom
Mark2000-patch-1

Conversation

@Mark2000
Copy link
Copy Markdown
Contributor

@Mark2000 Mark2000 commented Aug 2, 2024

Description

This is slower than the python default hash function for the Target object.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How should this pull request be reviewed?

  • By commit
  • All changes at once

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Passes Tests

  • Unit tests pytest --cov bsk_rl --cov-report term-missing tests/unittest
  • Integrated tests pytest --cov bsk_rl --cov-report term-missing tests/integration
  • Documentation builds cd docs; make html

Test Configuration

  • Python: 3.11
  • Basilisk: 2.3
  • Platform: Mac

Checklist:

  • My code follows the style guidelines of this project (passes Black, ruff, and isort)
  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation and release notes
  • Commit messages are atomic, are in the form Issue #XXX: Message and have a useful message
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • If I changed an example ipynb, I have locally rebuilt the documentation

self._id = f"{self.name}_{id(self)}"
return self._id

def __hash__(self) -> int:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To check if I understood it right, the hash will now be generated based on the entire object, and not only on its id, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not sure why I put this in in the first place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, it may be worth checking how targets are copied, if ever. I believe deepcopy changes the hash but not the id, so this could potentially lead to issues. I'll take a closer look at some point; not a big enough performance improvement to warrant potentially introducing an error without being sure of this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I hadn't considered that before, but I agree. This is a subtle change that can lead to unexpected consequences.

@Mark2000 Mark2000 marked this pull request as draft September 23, 2024 17:17
@Mark2000
Copy link
Copy Markdown
Contributor Author

Closing, included in #301

@Mark2000 Mark2000 closed this Sep 30, 2025
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.

2 participants