python-phonenumbers icon indicating copy to clipboard operation
python-phonenumbers copied to clipboard

Embracing Cython 3.0 pure python mode to speed-up the library

Open msaelices opened this issue 2 years ago • 2 comments

Recently, Cython released the 3.0 version with a Pure Python mode, and I think it would be a game changer in this library, as most of the code is just Python logic using basic types.

Having all the parsing and validation logic running at C speed would be awesome.

The only downside is the library would need to drop support for Python 2, but: is this really a piece of bad news?

I could help with the optimization.

msaelices avatar Sep 20 '23 12:09 msaelices

Does supporting Cython just involve maintaining parallel .pxd files, similar to the .pyi files that already have parallel type information?

Also, why would Cython support require removal of Python 2 support?

daviddrysdale avatar Sep 20 '23 15:09 daviddrysdale

There's also mypyc, which uses type hints to compile to C.

maintaining parallel .pxd files

It seems like Cython would work even absent the .pxd files, but adding them increases the information provided to Cython and hence the speed-up is greater.

AA-Turner avatar Sep 20 '23 20:09 AA-Turner