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

Make GILOnceCell<Py<PyType>>'s get_or_try_init_type_ref public #4516

Closed
glevco opened this issue Sep 3, 2024 · 4 comments · Fixed by #4542
Closed

Make GILOnceCell<Py<PyType>>'s get_or_try_init_type_ref public #4516

glevco opened this issue Sep 3, 2024 · 4 comments · Fixed by #4542

Comments

@glevco
Copy link
Contributor

glevco commented Sep 3, 2024

Hi!

Is there any reason why GILOnceCell<Py<PyType>>'s get_or_try_init_type_ref() is not public API? It's a useful function and it looks like it should be the default way of importing Python modules. I would be happy to open a PR changing it and updating the docs accordingly, if it makes sense.

Thanks in advance!

@davidhewitt
Copy link
Member

Hey, thanks for the request. There's a couple of different factors at play here:

  • eventually, we should probably use "module state" for extension modules to store things like imports. This is still a way off but I think the way the CPython team wants us to do things instead of using GILOnceCell.
  • There is also some debate about the immediate future for GILOnceCell. The python 3.13 freethreaded build removes the ability to synchronize using the GIL, so we are exploring solutions like make GILOnceCell threadsafe #4512 and add OnceLockExt extension trait to help initialize OnceLock #4513

So overall, it's not the best time to be expanding the GILOnceCell API until we are more sure of its future direction.

@davidhewitt
Copy link
Member

That said, we just merged #4511 so maybe it's fine to make this public for the short term. PR would be accepted.

@glevco
Copy link
Contributor Author

glevco commented Sep 4, 2024

Ok, thanks! I'll work on it.

@glevco
Copy link
Contributor Author

glevco commented Sep 10, 2024

@davidhewitt Done in #4542, can you please review it?

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

Successfully merging a pull request may close this issue.

2 participants