News for hackers. Stuff that matters.
Re:Show HN: Python Source Code Refactoring Toolkit via AST by TekMol on Sunday August 01, 2021 @11:59AM (#28027225)
The one thing I hope for when it comes to Python is that PyPy becomes the default runtime everywhere.

CPython is so unbelievably slow when compared to languages like PHP and Javascript.

When using PyPy, I keep encountering road bumps because many tools are still expecting that one uses CPython.

Dear world - please accelerate the conversion to PyPy!

Re:Show HN: Python Source Code Refactoring Toolkit via AST by keithasaurus on Sunday August 01, 2021 @12:10PM (#28027335)
I think it's more likely that people start using mypyc for performance-critical code. https://mypyc.readthedocs.io/en/latest/
Re:Show HN: Python Source Code Refactoring Toolkit via AST by formerly_proven on Sunday August 01, 2021 @12:25PM (#28027473)
I assume the performance profile is similar to compiling regular Python code with Cython (which it can do). There is a decent but not world-changing speed-up; this makes sense, because pretty much the only thing you are removing from the equation is the instruction and stack overhead of the interpreter, you still have to perform all the equivalent work that CPython does, otherwise you would end up with different semantics. And this work is substantial.

In contrast, a tracing JIT can dynamically elide most of this work without changing the semantics.

Re:Show HN: Python Source Code Refactoring Toolkit via AST by xapata on Sunday August 01, 2021 @02:42PM (#28028753)
After switching to Cython, you can add Cython syntax, like type definitions, to gain big speed improvements.
Re:Show HN: Python Source Code Refactoring Toolkit via AST by rattray on Sunday August 01, 2021 @01:32PM (#28028190)
Wow, this looks exciting. Looks like Cython without any extra work/syntax, for those using mypy.

I wish their readme gave some kind of estimate of how the speedups might compare to Cython and PyPy. But it's currently alpha, so there may be big differences by the time it's ready for production use.

Similar approach to the Sorbet Compiler for Ruby (albeit targeting C instead of llvm... I wonder how that might impact optimizability).

Re:Show HN: Python Source Code Refactoring Toolkit via AST by treesciencebot on Sunday August 01, 2021 @12:05PM (#28027301)
Author of this project here (and also a CPython core developer FWIW), for many aspects (including the AST) PyPy follows CPython closely even on implementation details so `refactor` would probably work out of the box once PyPy releases 3.9 (the latest stable version for PyPy is 3.7, and 3.8 is on the way!).
Re:Show HN: Python Source Code Refactoring Toolkit via AST by heavyset_go on Sunday August 01, 2021 @03:23PM (#28029067)
Projects that depend on CPython C extensions should consider migrating to HPy[1] for C extension compatibility across Python implementations.

[1] https://github.com/hpyproject/hpy

Re:Show HN: Python Source Code Refactoring Toolkit via AST by sitkack on Sunday August 01, 2021 @03:52PM (#28029289)
This looks interesting, but it also looks ambitious and not anywhere ready. Everyone would be well served for extensions to not be aware of Python internals and expose a clean handle based api to all users. For this, cffi is sufficient and already available across nearly all Python implementations.

https://cffi.readthedocs.io/en/latest/

I do agree that a standardized Python should have an object model that is a clean public contract, but given that Python is CPython and there is no standardization, that the library runtime is married to the core also makes this incredibly difficult politically.

Re:Show HN: Python Source Code Refactoring Toolkit via AST by hsbauauvhabzb on Sunday August 01, 2021 @07:48PM (#28031393)
is performance even an issue either the tool? I regularly see people complain about python speed but normally find it’s algorithmic as opposed to interpreter imposed..