-
-
Notifications
You must be signed in to change notification settings - Fork 18
Remove lifetime #22
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
Remove lifetime #22
Conversation
src/lib.rs
Outdated
@@ -191,7 +192,7 @@ impl<'a, T> PathTree<'a, T> { | |||
self | |||
} | |||
|
|||
pub fn find<'b>(&'a self, path: &'b str) -> Option<Path<'a, 'b, T>> { | |||
pub fn find<'a, 'b>(&'a self, path: &'b str) -> Option<Path<'a, 'b, T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the lifetime for path would be fine to keep. For PyO3 we need to copy the data into Python objects to return it anyway, so lifetimes on methods are fine. The problematic lifetimes are on the PathTree. Also I imagine most use cases don’t care too much about insertion times (ideally that would happen once at app startup) so I would heavily bias toward optimizing the performance of find() over all else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change better? I decided to make it an elided lifetime instead of explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, I’ll try updating the wrapper and confirm. By the way, if you have any input there feel free to open a PR, I’m still learning so I’m sure you could improve it.
The biggest performance problem when capturing parameters. |
From my profiling I did notice that each I'll take a look into inserting paths, one of the ideas I had was to store the inserted paths in What was the issue with capturing parameters. I did notice a second parameter check not sure if thats what you're talking about though. |
Updates parameters array, https://github.com/viz-rs/path-tree/blob/main/src/node.rs#L284-L285, if this update operation is removed, the code will be greatly enhanced. So I'm wondering if there's a better way to update the array. |
Ah those, I was wondering about those. My initial thoughts were to just place them into a single insert (eg: My other idea was to have each 'leaf' |
Using Range is very clean and simple.
Yes we already have the path pieces that seem to do. |
If it is possible to merge, assign to me. :) |
I fixed the merge conflict but I am unable to assign you to the issue as I don't have the ability to do so. |
@Txuritan I have invited you to role write. |
Landed in v0.5.1. Thanks. |
This worked out great for the Python wrapper: adriangb/routrie@faa4ad8#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759 It would be nice to figure out at some point how to lazily build the parameters instead of calling |
A mentioned in #18 the added lifetime would limit use of the API as well as cause issue with PyO3 bindings. This removes it using
Vec
s andto_vec
s.I do plan on using this commit as the basis for my optimization experiments which may be included depending on if this is merged or not.
Benchmark (mimalloc):
Benchmark (Windows' allocator):