yaml / pyyaml

Canonical source repository for PyYAML
MIT License
2.54k stars 515 forks source link

Can PyYAML benefit from PEP 703 (making the GIL optional)? #718

Open gabrieldemarmiesse opened 1 year ago

gabrieldemarmiesse commented 1 year ago

Hi!

I'm Gabriel de Marmiesse and I'm helping Sam Gross to find out if maintainers of selected Python packages would benefit from PEP703.

If you don't know what is PEP 703, it's about making the global interpreter lock (GIL) optional. Long story short, there would be a ~10% performance impact on single threaded programs, but would allow multithreaded programms to take full advantage of multiple cores. You can play with it here.

If you have the time, we would like to know is if the maintainers of PyYAML would benefit from PEP 703 or not. There are multiple situation PyYAML could be in.

1) PyYAML already uses threads and PEP 703 will likely make some features faster by allowing parallelization of cpu computation without any change. 2) PyYAML doesn't use threads, but PEP 703 would allow you to rewrite some features with multithreading, thus making it faster. 3) PyYAML uses multithreading with a low-level language (rust, C, C++...) or multiprocessing and using PEP 703 would allow a rewrite and lower the maintenance burden. 4) There is no computation that can be parallelized. 5) PyYAML wouldn't use multithreading, but it's very likely that users will call this package functions and classes from multiple threads because the workload can often be parralelized.

The Python language could never use multiple cores with multithreading, so it's hard to imagine what the future of the language would look like if we were to enable it. Feel free to tell us if you see new potential use cases with this PEP. Thanks for your time!

If you want to know more about PEP 703: