-
-
Notifications
You must be signed in to change notification settings - Fork 919
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
Fastest way to get the latest commit? #240
Comments
I don't think so. My general advice is to use a git.Repo(path, odbt=git.GitCmdObjectDB) The operation you try to perform is inherently expensive, and I believe there is no better way if caches cannot be used. The second approach seems to be best, as you inherently use the git command to apply the path filter, and then python to find the actual commit per path. However, Also I believe you should profile your application to actually see where the time is spend, maybe more ideas arise from that. I'd be interested to learn about your findings - please feel free to post them here. |
Thanks for your reply. Here are some findings from my tests. test1.py:
test2.py:
test3.py:
Here is a call graph of test3: If i read it correctly,
|
Thanks for sharing your results ! I was quite surprised to see
It would of course be even more interesting to see how fast pygit2 (bindings to libgit2) can be - apparently they have the required |
I've redone the test with test1 and test2 - test2 is on average only slightly faster (500ms). I have looked at pygit2 which feels faster but has a lot worse interface. Unfortunatly, |
Ah, I was confused for a moment, but finally understood that pygit just doesn't yet bind to it. Interesting is that they indeed implement this binding manually ! It's amazing that people still do this nowadays, as I believed binding generators are the standard way to approach this issue. Maybe with a little bit of luck, they will get to it soon so you can give that one a shot. |
@ercpe looks like it's implemented now |
I'm trying to get the latest commit for each item in a list of
Tree
orBlob
objects (sth. like a repo browser). Currently i'm doing something likebut this is incredible slow. Another solution is to use
repo.iter_commits()
to fill a dict of path <-> commit:However, in the worst case this one iterates over all commits in the entire repository (which is obviously a very bad idea).
Is there a faster solution?
The text was updated successfully, but these errors were encountered: