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

Property path_name can be made more efficient #67

Closed
lverweijen opened this issue Jul 10, 2023 · 2 comments · Fixed by #68
Closed

Property path_name can be made more efficient #67

lverweijen opened this issue Jul 10, 2023 · 2 comments · Fixed by #68
Labels
enhancement New feature or request

Comments

@lverweijen
Copy link

See

return f"{self.parent.path_name}{self.sep}{self.name}"

The property path_name references sep, but the property sep is itself recursive, so it takes k^2 lookups but only k lookups are needed. Furthermore, it does string addition in a (recursive) loop, but there are better ways to construct strings.

Perhaps change this to:

self.sep.join(reversed(self.ancestors))

or probably even faster:

ancestors = list(self.ancestors)
sep = ancestors[-1]._sep  # No recursion because sep is taken directly from root
return sep.join(reversed(ancestors)
@lverweijen lverweijen changed the title Property path_name can be made more effecient Property path_name can be made more efficient Jul 10, 2023
@kayjan kayjan added the enhancement New feature or request label Jul 11, 2023
@kayjan
Copy link
Owner

kayjan commented Jul 13, 2023

Thanks for this suggestion! This will be implemented in v0.9.5 😄

@kayjan
Copy link
Owner

kayjan commented Jul 13, 2023

v0.9.5 is now live, do upgrade bigtree with pip install --upgrade bigtree to get the latest changes.

@kayjan kayjan closed this as completed Jul 13, 2023
@kayjan kayjan linked a pull request Oct 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants