-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
[C API] Add PySet_NextEntry() function #121125
Comments
cc @AdamWill |
Meta: why the |
I added "pending" label by mistake, I don't know how. Removed. |
Why is this better than |
I'm ok if we decide to not add a new function for Blender. Proposed API is similar to PyDict_Next() with a pos parameter set to 0 at start. It's simpler to use, there is no iterator to manage. I also expect it to be faster. |
Poking around, it's also used in Numba. PyO3 (Rust bindings for Python) used to use it but changed that recently in PyO3/pyo3#3849 . llvm-opt-benchmark seems to use it, but I think that's just benchmarking how fast it is when you build CPython with LLVM or something; presumably they could just...stop benchmarking that specific function. Everything else I can find at least in github universal search is some kind of fork or copy of CPython or one of the other users, or an alternative Python interpreter providing its own version. |
Do you want to add only See #43090 for discussion about cc @rhettinger |
I expect the function to work on set, frozenset and subclasses. |
I prefer people to just use The |
FWIW, it was an intentional decision to not make this a public API. The API was carefully thought out to provide what most people need from a set object. Implementation details, optimization hacks, and fragile interfaces were avoided. For the most part, this has served us well. |
@AdamWill: Well, it seems like Blender, other mentioned projects, have to be updated to PyObject_GetIter() and PyIter_Next(). |
Thanks, I'll update the downstream issue. If anyone wants to help with that it would be great, I like to try and help projects with these transitions where possible but I'm not much of a C coder. |
Feature or enhancement
The
_PySet_NextEntry()
function was removed in Python 3.13 alpha 1, but it's used by the Blender project: https://projects.blender.org/blender/blender/search?q=_PySet_NextEntryI propose adding a new function to replace it:
*key
to a strong reference, and return 1 on success.Differences with
_PySet_NextEntry()
:The text was updated successfully, but these errors were encountered: