DEP: Deprecate 'fix_imports' flag in numpy.save#26452
Conversation
seberg
left a comment
There was a problem hiding this comment.
Thanks a lot, always good to get a deprecation started!
For Python deprecations it is a bit less of a worry, but we should add a short test to the numpy/_core//tests/test_deprecations.py file.
numpy/lib/_npyio_impl.py
Outdated
| will try to map the new Python 3 names to the old module names used in | ||
| Python 2, so that the pickle data stream is readable with Python 2. | ||
| The `fix_imports` flag is deprecated and has no effect. | ||
| .. deprecated:: 2.0 |
There was a problem hiding this comment.
I would lean towards just not backporting, doesn't seem much of a deal. @charris want to make the call?
numpy/lib/_npyio_impl.py
Outdated
| Historically, this flag was used to control compatibility support | ||
| for objects saved in Python 3 to be loadable in Python 2. This flag | ||
| is ignored after NumPy 1.17, and deprecated in NumPy 2.0. It will | ||
| be removed in a future release. |
There was a problem hiding this comment.
Looks good as is, might suggest to shorten it a bit: This flag is ignored since NumPy 1.17 and was only needed to support loading some files in Python 2 written in Python 3.
|
Thanks @vxst! |
|
Was about to merge and then I realized that this needs a release note too. Can you add one? |
|
Of course |
|
Sorry that I forgot deprecation needs a release note. |
Since NumPy upgraded the pickle protocol version to 3 in version 1.17, the
fix_importsflag is ignored by the pickle library. To reduce confusion, I propose removing this flag in a future release.However, since many people actually use
numpy.save(..., allow_pickle=True, fix_imports=True)as default behavior (for example, see this example: intel/intel-extension-for-transformers), removing thefix_importskeyword may break compatibility with existing code.Following NEP 23, I suggest adding a check for the usage of the
fix_importskeyword and emitting aDeprecationWarningfor any usage.