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

Work In Progress: Du Toit's Pillow Port to HPy #1

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

DuToitSpies
Copy link

My port of Pillow to HPy so far: currently I have ported most of the Image class, as well as the ImageMorph class.

}

PyObject *py_size = HPy_AsPyObject(ctx, h_size);
PyObject *py_kernel = HPy_AsPyObject(ctx, kernel);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that HPy_AsPyObject increments ref count before returning the underlying PyObject* to you, so you should Py_DECREF(py_kernel) when you're done with it (or leave it be and fix it by migrating it all to HPy).

src/_imaging.c Outdated
PyObject *color = HPy_AsPyObject(ctx, h_color);

x = PyLong_AsLong(PyTuple_GetItem(coords, 0));
y = PyLong_AsLong(PyTuple_GetItem(coords, 1));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this shows often, I think we can reconsider the support for tuple deconstruction in HPyArg_Parse. Once this is proper HPy code, it will be even more bloated, because you'll have to HPy_Close all the items retrieved from the tuple.

src/_imaging.c Show resolved Hide resolved
@@ -121,7 +122,7 @@ typedef struct {
ImagingAccess access;
} ImagingObject;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to directly convert between structs like this and an HPy type, without having to go through a PyObject?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HPy_AsStruct. I think the best knowledge source for now are the tests in the HPy repository. Maybe this is something we can improve in the docs..

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

Successfully merging this pull request may close these issues.

3 participants