
Hi, While in PyPy was possible to pickle a generator function and resume after unpicking this does not happen with PyPy3: File "/snap/pypy3/72/lib-python/3/pickle.py", line 942, in save_global (obj, module_name, name)) pickle.PicklingError: Can't pickle <class 'generator'>: it's not found as builtins.generator Is this a bug or this feature is removed in PyPy3? Thanks, Yannis

According to issue 3150 https://foss.heptapod.net/pypy/pypy/-/issues/3150, this is on purpose, and brings us into feature compatibility with CPython: Python 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information.
I guess we could improve the error message to be more helpful. Do you have a concrete use case for this? Matti. On 12/11/20 1:55 PM, Ioannis Foufoulas wrote:

On Fri, Dec 11, 2020 at 03:21:18PM +0200, Matti Picus wrote:
The inability to pickle an object is not a feature, it is the lack of a feature. I think this is a case where PyPy initially did the right thing and then threw it away. I'm not satisfied by the arguments given here: http://peadrop.com/blog/2009/12/29/why-you-cannot-pickle-generators/ https://bugs.python.org/issue1092962 for CPython to not pickle generators, but pickling generators is not forbidden by the language, it is a quality of implementation issue. In this instance, both Stackless and PyPy 2 had better implementations than CPython.
I guess we could improve the error message to be more helpful. Do you have a concrete use case for this?
You have a generator which you are iterating through, and you want to stop your program and resume later. Or resume immediately but from another process. -- Steve

Hi Steven, hi all, I don't think it's a huge intentional thing that we don't support this feature in PyPy3. It's mostly that nobody was motivated enough to implement it (as Armin said in the linked issue). So if somebody wants to tackle it, we'd be happy to merge it! Cheers, CF On 11.12.20 21:49, Steven D'Aprano wrote:

According to issue 3150 https://foss.heptapod.net/pypy/pypy/-/issues/3150, this is on purpose, and brings us into feature compatibility with CPython: Python 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information.
I guess we could improve the error message to be more helpful. Do you have a concrete use case for this? Matti. On 12/11/20 1:55 PM, Ioannis Foufoulas wrote:

On Fri, Dec 11, 2020 at 03:21:18PM +0200, Matti Picus wrote:
The inability to pickle an object is not a feature, it is the lack of a feature. I think this is a case where PyPy initially did the right thing and then threw it away. I'm not satisfied by the arguments given here: http://peadrop.com/blog/2009/12/29/why-you-cannot-pickle-generators/ https://bugs.python.org/issue1092962 for CPython to not pickle generators, but pickling generators is not forbidden by the language, it is a quality of implementation issue. In this instance, both Stackless and PyPy 2 had better implementations than CPython.
I guess we could improve the error message to be more helpful. Do you have a concrete use case for this?
You have a generator which you are iterating through, and you want to stop your program and resume later. Or resume immediately but from another process. -- Steve

Hi Steven, hi all, I don't think it's a huge intentional thing that we don't support this feature in PyPy3. It's mostly that nobody was motivated enough to implement it (as Armin said in the linked issue). So if somebody wants to tackle it, we'd be happy to merge it! Cheers, CF On 11.12.20 21:49, Steven D'Aprano wrote:
participants (4)
-
Carl Friedrich Bolz-Tereick
-
Ioannis Foufoulas
-
Matti Picus
-
Steven D'Aprano