Skip to content
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

Hello, HPy | HPy #6

Open
utterances-bot opened this issue Mar 29, 2021 · 10 comments
Open

Hello, HPy | HPy #6

utterances-bot opened this issue Mar 29, 2021 · 10 comments
Labels

Comments

@utterances-bot
Copy link

Hello, HPy | HPy

https://hpyproject.org/blog/posts/2021/03/hello-hpy/

Copy link
Contributor

mattip commented Mar 29, 2021

Can't wait to hear more.

@mattip mattip added the Comments label Mar 29, 2021 — with utterances
Copy link

magicl commented Mar 29, 2021

This is great. Looking forward to a more compatible PyPy due to this work, so we can actually start using it :) . Keep it up!

Copy link

lostmsu commented Mar 30, 2021

Is this going to cover embedding scenarios as well as extension development? CPython API does that.

Copy link
Contributor

@lostmsu From the API point of view, there is nothing in HPy which would prevent to use it for embedding, so eventually we will also support that.
However, the first priority for now are extensions.

@lostmsu
Copy link

lostmsu commented Mar 30, 2021

@antocuni embedding into non-C languages precludes using C macros to define new objects.

I think if API is not designed with that in mind, it will have the same problems as CPython has for embedding.

@antocuni
Copy link
Contributor

@lostmsu macros are not required to write HPy extensions. Unfortunately HPy is a bit under-documented now and it's not easy to find info about this, but the various macros like HPyDef_METH & co. are there just to simplify the life of the users. It is possible to do things manually and define HPyDef by hand.

This is an example taken from ultrajson-hpy:

// ujson.c does something a bit weird: it defines two Python-level methods
// ("encode" and "dumps") for the same C-level function
// ("objToJSON_impl"). HPyDef_METH does not support this use case, but we can
// define our HPyDef by hand: HPyDef_METH is just a convenience macro and the
// structure and fields of HPyDef is part of the publich API
HPyDef objToJSON_encode = {
   .kind = HPyDef_Kind_Meth,
   .meth = {
       .name = "encode",
       .impl = objToJSON_impl,
       .cpy_trampoline = objToJSON_trampoline,
       .signature = HPyFunc_KEYWORDS,
       .doc = ("Converts arbitrary object recursively into JSON. "
               ENCODER_HELP_TEXT),
   }
};

Copy link

Great article!

Minor note: should .m_name = "hello_old", be .m_name = "hello_new, instead?

@antocuni
Copy link
Contributor

@aneeshdurg you are correct, thanks for reporting. Fixed by 935e8f6, should appear online soon

Copy link

Very interesting. When do you expect the first official release?

@antocuni
Copy link
Contributor

antocuni commented Apr 2, 2021

@PimvanderEijk it depends on how you define "official".

We recently agreed that it's a good idea to start tagging some git versions with release numbers: this will simplify the interactions with hpy, pypy and grallpython. Once we do that, we might or might not decide to also publish the releases on PyPI, but this should be a minor thing as anyone who is brave enough to try hpy at this stage should not have problems at installing it from git.

However, note that even if we start to roll out releases, we are not making any commitment of compatibility between them at this stage. The API is still subject to change completely between one release and the next, see e.g. hpyproject/hpy#182.

If the question is "when do we expect to roll out a release on which people can rely to write and distribute their own extensions", I think it will be several months from now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants