-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add dictionary type to HPy #458
Conversation
The error in |
I am a bit troubled by the many shape objects. They are used to access low-level, implementation specific APIs for the different objects, right? Isn't there a way to tell cython "hey, don't do that"? The type objects are opaque on PyPy, so from my very small world this is unneeded complication. |
The shapes provide a means to access the internal struct of built-in objects after the PyObject header part. It mimics what happens for user defined subclasses. It's needed for cases where an extension subclasses built-in types, I think. Someone else please correct me if needed. @mattip has a point here though -- to what extent are these additional pieces of data really a CPython implementation detail? One could make a good argument that they are entirely an implementation detail. The question then is whether we can provide a better porting path for existing libraries, or whether implementations just have to mimic this and possibly be slow? |
Yes there is but that is not unrelated to the shapes. What Du Toit needs for his Cython/HPy work is essentially
I can understand this. The built-in shapes are not intuitive. I would like to raise your attention to #169 (and the implementing PR #335). Since the issue and PR are a lot of reading, I try to summarize here:
Yes, you can. It could be considered as an implementation detail. But this is similar to, e.g., |
@fangerer Maybe I misunderstood how the shapes are used then. Do we just need their size? And do we only really need them on CPython? |
We don't strictly need them at all. As I wrote, we could store the information in Line 345 in bdf7e7f
The built-in types are just an additional information that can help interpreters.
No, the size would not help alternative implementations. E.g. in GraalPy, we are not allocating objects by size (as CPython does), we are allocating them using a Java class. But it helps GraalPy because we could store the user data pointer in a well-known location of the appropriate Java class. |
Even if this PR raised some discussions about the built-in shapes, I will merge it because this PR is just adding one (missing) shape. So, if built-in shapes are the problem, not merging this PR would solve it. |
@fangerer Very happy for this to be merged. Let's add the shape discussion for the agenda of the next dev call. |
Adds h_DictType to HPy, as this is needed for the Cython port.