-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Is Cython for performance a 'good idea'? #2405
Comments
@kodonnell Thanks for initiating this discussion. Other than that, I would say the most of the pylint's performance problems are actually coming from
|
Also I'm closing this not necessarily because I'm opposed to the idea, but we don't have as much time as this effort requires. |
Thanks @PCManticore, and I understand where you're coming from. It's good to have this documented for others (e.g. @nickdrozd who mentioned this possibility in his PRs, if I remember correctly). Question: if somebody (maybe me or maybe someone who reads this) did a proof-of-concept cythonizing of astroid, and the results were promising (e.g. minimal code change but performance is doubled) would that change the situation much? I guess what I'm really asking is whether there's much point in me investigating this further. Another alternative (which may be cleaner) could be for someone to start a Cython fork of astroid and, if it's up-to-scratch, simply allow pylint to use either one. In other words "PyCQA will maintain and support pylint with astroid. We allow for the use of in pylint, but it's at your own risk and not supported" etc. That could also allow you to gauge how much interest there is, etc. Re type annotation - that wouldn't have any impact for me (or most of the open source projects I see which don't seem to use it - though that may change). |
@kodonnell yes, definitely. If you or anyone else will come up with a Cythonized astroid fork that has improved performance, we'll be definitely keen on integrating that into astroid itself. I'd love a faster pylint, I just cannot commit myself on working on this project. |
Understood. No promises here, in part as I need to wrap my head around AST and astroid etc. But, it might be fun. And kind of neat in how many people it could benefit. If someone reading this does plan to start such a cython fork, can you add a comment below, so we can keep an eye on progress (if any)? If you're just a general fan of the idea, but not willing to fork yourself, maybe just a thumbsup, so we can track interest? As an aside, I wonder how much power pylint/astroid consumes in all its uses worldwide? (And hence, how much performance improvements matter.) That'd be a fun calculation. |
Quick update @PCManticore - I've done a quick hack to just cythonize the plain python - note that very little code has changed. If you want to run it: Note that I couldn't 'naively' apply this to some of the files (seemingly inference.py and raw_building.py if I remember rightly) due to the dynamic assignment of methods not working out-of-box in cython - see here. Nonetheless, when running it on Also - do you want me to move this issue to astroid? |
That sounds amazing @kodonnell ! Yes, let's move this to astroid, we can then figure out what needs to be done to package, ship and test this. |
Great, I'll start a WIP PR or something this weekend. It's worth noting that this same sort of naive cythonization could be applied to pylint - though my understanding is that astroid's the main bottleneck, so it might not be worth it. |
@PCManticore do you think this should be re-opened given the results above? |
Is using Cython to enhance the performance of pylint (and astroid) a 'good idea'? Specifically:
yields
)?The idea would be we're in a happy medium where some core performance critical code is Cython (with maybe a bit of C), while the bulk of the 'business logic' for different linting rules etc. are still in python (as these are the parts most likely to be contributed by the community etc.?). Then again, some of these tried-and-true ones could be cythonized too, etc.
The text was updated successfully, but these errors were encountered: