Coder Social home page Coder Social logo

Suggestion: Use Cython about pygit2 HOT 11 CLOSED

libgit2 avatar libgit2 commented on August 15, 2024
Suggestion: Use Cython

from pygit2.

Comments (11)

jdavid avatar jdavid commented on August 15, 2024

Hello,

I don't like much the idea. Here are other, closely related, disadvantages:

  • Will make pygit2 vulnerable to Cython bugs
  • Loss of control on the generated C code
  • Likely not as fast (related to the reason above)

It is impressive how you have rewritten pygit2 in just one day, it speaks well of the virtues of Cython. But I don't think it is the best fit for pygit2.

The Python community is quite large and interest on libgit2 should raise overtime; pygit2 is already relatively well maintained, 13 people have contributed so far with patches, others have done so by reporting issues. I think libgit2 deserves hand-written carefully tuned Python bindings, and that there will be enough developers/testers interested to make it happen.

Best regards,

from pygit2.

esc avatar esc commented on August 15, 2024

Hi,

i have been thinking about writing cython bindings for libgit2. I think the issue of handwritten vs. Cython is not an either or question, but i think that both bindings (I would call the Cython ones cygit2) should co-exist. This would mean the cython bindings would have to be 100% api compatible to the handwritten ones which AFAICS is currently the case since the Cython bindings use the unit-tests. One could think about introducing a flag allowing the programmer to select an appropriate 'backend' to give the choice to the user.

I think both wrapping approaches have their merits and both can learn from each other.

from pygit2.

jdavid avatar jdavid commented on August 15, 2024

I find that proposal (pygit2 and cygit2) interesting, it looks there are more than enough developers interested in one or another, or both (searching a little I found someone else had the same idea, https://github.com/pyos/cygit2).

from pygit2.

encukou avatar encukou commented on August 15, 2024

It shouldn't be too hard to maintain the Cython bindings if the test suite is shared with the C-API pygit2, but it'll necessarily mean each would have less users/testers :(
Anyway, I'll be keeping them around at least until pygit2 supports Python 3.
I've contacted pyos to see what he thinks.

As for speed... my code is about 10% slower on the test suite, and I didn't try to optimize at all. The test suite is not a good benchmark, though – there's a lot of exception raising; I think Cython's detailed tracebacks are better than speed here.
And talking about speed is useless without a good benchmark, so I'll end here.

from pygit2.

jdavid avatar jdavid commented on August 15, 2024

How to share the unit tests? Maybe you could use Git submodules?

I have open an issue for Python 3 support.

Regarding speed, for what I need pygit2 for, 1% slower would already be too much. It depends on the usage scenario I guess, in my case I use Git as a brick in a database system used in a web application (many requests from clients, blah blah ...).

from pygit2.

encukou avatar encukou commented on August 15, 2024

Git submodules are quite a hassle in my opinion (unless the linked project is big), not to mention libgit2 doesn't really have them yet. I can just continue to pull from pygit2, and ignore the non-test changes.

from pygit2.

 avatar commented on August 15, 2024

Actually, I decided to write cygit2 because I like Python 3, but I don't know C good enough. It would be awesome if you could add support for py3k without using cython.

And if you care about speed that much, you chose the wrong language to write your web application in :-)

from pygit2.

jdavid avatar jdavid commented on August 15, 2024

Support for Python 3 has been started.

from pygit2.

jdavid avatar jdavid commented on August 15, 2024

Just to comment about the speed stuff and more precisely how I see pygit2.

I think pygit2 should be low-level, expose the features of libgit2 to the Python developer and that's it.

Then I guess other developers will use it to write higher level libraries with richer functionality. I believe the developer of GitPython has already started to use pygit2, maybe Dulwich will follow. I myself maintain such a library (itools.git).

This is important. It is related for instance to question discussed in issue #43, whether pygit2 should accept unicode strings for the Hex SHAs or not.

Cheers,

PS : @pyos you are right Python is not the best choice regarding speed, but...

from pygit2.

tmc avatar tmc commented on August 15, 2024

For what it's worth in my initial tests I see very small to no difference in overhead, I haven't taken the time to construct an accurate rig but it should be the case that the same speeds can be accomplished with about half of the code to maintain.

from pygit2.

jdavid avatar jdavid commented on August 15, 2024

Time to close this issue. If somebody is interested to develop cygit2 just go ahead. Thanks.

from pygit2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.