There is a small change I would like to make to a popular Python library for a library I wrote to work.
Specifically, the scikit-learn library has the following code snippet in this file:
from pickle import whichmodule
try:
# Python 2 compat
from cPickle import loads
from cPickle import dumps
except ImportError:
from pickle import loads
from pickle import dumps
import copyreg
# Customizable pure Python pickler in Python 2
# customizable C-optimized pickler under Python 3.3+
from pickle import Pickler
from pickle import HIGHEST_PROTOCOL
That I would like to change to this:
from pickle import whichmodule
from dill import loads
from dill import dumps
import copyreg
# Customizable pure Python pickler in Python 2
# customizable C-optimized pickler under Python 3.3+
from dill import Pickler
from dill import HIGHEST_PROTOCOL
Currently, I am changing the file manually and it works.
If there was a way for me to save this one changed file to the repo I wrote that uses scikit-learn and have magic happen so that when I import scikit-learn in my repo, the import used my updated version of the file instead of the standard one, that would be amazing.
This question was helpful if I wanted to fake out a local import of pickle, but wasn't applied to scikit-learn's import of pickle.