yglukhov / nimpy

Nim - Python bridge
MIT License
1.46k stars 62 forks source link

Add support for Hpy #245

Open Yu-Vitaqua-fer-Chronos opened 2 years ago

Yu-Vitaqua-fer-Chronos commented 2 years ago

Maybe try intergrating Hpy instead of the CPython ABI? Or potentially add a way to choose which one you use? It'd be a good idea to intergrate this because while PyPy (and potentially other implementations) support the CPython ABI to some capacity, it's slow and inefficient, using something like https://github.com/hpyproject/hpy would be beneficial as it wouldn't have to translate the CPython ABI calls as much and would increase compatibility between Python implementations, making Nimpy more versatile

ghost commented 2 years ago

@Mythical-Forest-Collective maybe I'm wrong, but isn't Hpy aimed at making another API for writing native extensions for Python? Because that's only the half of what nimpy does - it also uses CPython API to allow you to call Python code from Nim.

yglukhov commented 2 years ago

Looks interesting, but I'd wait for it to settle down a bit, official release is still TBD.

Yu-Vitaqua-fer-Chronos commented 2 years ago

@Mythical-Forest-Collective maybe I'm wrong, but isn't Hpy aimed at making another API for writing native extensions for Python? Because that's only the half of what nimpy does - it also uses CPython API to allow you to call Python code from Nim.

I'm mainly talking about making extensions with HPy, as that'd allow Nimpy to work on different interpreters a lot easier and faster (PyPy implements HPy and extensions using HPy are a lot faster), and it is also possible (from what I've read in their docs), to compile HPy extensions for the C Python API. The project isn't completely done yet but slowly adding in support for HPy over CPython's ABI would be beneficial in the long term

Looks interesting, but I'd wait for it to settle down a bit, official release is still TBD.

Yeah fair enough, just thought i should bring it here for possible future reference

Yu-Vitaqua-fer-Chronos commented 1 year ago

Heya, it's approaching the end of 2022 and I'm wondering if you think this would beneficial for Nimpy with HPy's current state? GraalPython also supports HPy and looks like the folks at RustPython are interested in it, and are planning to implement it at some point since it's gaining attention in the Python community (and note that HPy can be implemented gradually, since it's made to allow for gradual code migration)

yglukhov commented 1 year ago

I'm wondering if you think this would beneficial for Nimpy with HPy's current state?

Does CPython implement it yet?

GalaxySnail commented 1 year ago

Does CPython implement it yet?

HPy is a third-party project (but not a part of stdlib). And certainly, HPy supports CPython.

Yu-Vitaqua-fer-Chronos commented 1 year ago

I'm wondering if you think this would beneficial for Nimpy with HPy's current state?

Does CPython implement it yet?

HPy can compile itself to CPython's ABI natively and has the benefit of working on other Python implementations with speeds much better than trying to reimplement CPython's API