You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
import Pickler class directly from the pickle module #458
uses _pickle module to import Pickler. However, as per python 3.8 documentation[0] this class is available directly in the pickle module.
from pickle import Pickler
works ok and it is equivalent to _pickle.Pickler
$ python
Python 3.9.7 (default, Nov 1 2021, 14:08:06)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from _pickle import Pickler as p
>>> import pickle
>>> p is pickle.Pickler
True
>>>
Hi @jvesely, Is there a rationale for changing from _pickle import Pickler to from pickle import Pickler, other than fixing cloudpickle on pypy 3.8? If not, i'd rather keep this line, which need not be changed for other implementations than pypy, and branch the behavior for pypy in other to restore compatibility between cloudpickle, and pypy >= 3.8
Hi @jvesely, Is there a rationale for changing from _pickle import Pickler to from pickle import Pickler, other than fixing cloudpickle on pypy 3.8? If not, i'd rather keep this line, which need not be changed for other implementations than pypy, and branch the behavior for pypy in other to restore compatibility between cloudpickle, and pypy >= 3.8
This is not specific to version >= 3.8. Python 3.7 includes pickler.Pickler [0] and the same short script proves that _pickle.Pickler and pickle.Pickler. The same is true for Python3.6 as well.[1]
according to the python3 specs [2]: "Users should always import the standard version,". Using _pickle is just a non-portable way of doing the same thing.
This non-portability goes beyond PyPY. The same docs [2]: "In Python 3.0, the accelerated versions are considered implementation details of the pure Python versions." so the names and availability of any _pickle attributes can change between CPython versions.
I hope that this problem will be solve.
Scikit-learn package uses cloudpickle inside. And it causes the same above problem.
Perhaps, there are a lot of people want to use pypy because their code like using scikit-learn that scientific calculation code may require a lot of calculation so need speed up.
So solved this will contribute to their work a lot.
Activity
jvesely commentedon Nov 3, 2021
This also fixes issues with pypy3.8:
pierreglaser commentedon Feb 4, 2022
Hi @jvesely, Is there a rationale for changing
from _pickle import Picklertofrom pickle import Pickler, other than fixingcloudpickleonpypy 3.8? If not, i'd rather keep this line, which need not be changed for other implementations thanpypy, and branch the behavior forpypyin other to restore compatibility betweencloudpickle, andpypy >= 3.8jvesely commentedon Feb 4, 2022
This is not specific to version >= 3.8. Python 3.7 includes
pickler.Pickler[0] and the same short script proves that_pickle.Picklerandpickle.Pickler. The same is true for Python3.6 as well.[1]according to the python3 specs [2]: "Users should always import the standard version,". Using
_pickleis just a non-portable way of doing the same thing.This non-portability goes beyond PyPY. The same docs [2]: "In Python 3.0, the accelerated versions are considered implementation details of the pure Python versions." so the names and availability of any
_pickleattributes can change between CPython versions.[0] https://docs.python.org/3.7/library/pickle.html#pickle.Pickler
[1] https://docs.python.org/3.6/library/pickle.html#pickle.Pickler
[2] https://docs.python.org/3.1/whatsnew/3.0.html#library-changes
bsnresearcher commentedon Apr 22, 2022
I hope that this problem will be solve.
Scikit-learn package uses cloudpickle inside. And it causes the same above problem.
Perhaps, there are a lot of people want to use pypy because their code like using scikit-learn that scientific calculation code may require a lot of calculation so need speed up.
So solved this will contribute to their work a lot.
jvesely commentedon Apr 22, 2022
@pierreglaser any ETA on a fix for this? It's rather straightforward. I can open a PR if needed.
pierreglaser commentedon Apr 22, 2022
Hey @jvesely, PR welcome, I'll review it.
compat: Import Picker from "pickle" instead of "_pickle"
compat: Import Pickler from "pickle" instead of "_pickle"
compat: Import Pickler from "pickle" instead of "_pickle"
compat: Import Pickler from "pickle" instead of "_pickle" (#469)
[SPARK-43348][PYTHON] Support `Python 3.8` in PyPy3
[SPARK-43348][PYTHON] Support `Python 3.8` in PyPy3