Feature Type
-
[x] Adding new functionality to pandas
-
[x] Changing existing functionality in pandas
-
[ ] Removing existing functionality in pandas
Problem Description
Python 3.14 will introduce compression.zstd as part of the standard library (PEP 784 and library documentation).
Currently, pandas uses the third-party zstandard library for Zstandard compression.
Would it be possible to also support the standard library implementation?
If not, we will need to keep using an external dependency even though an equivalent standard library module exists.
Feature Description
- From Python 3.14 onwards, use
compression.zstdinternally. - For Python 3.13 and earlier, use the
backports.zstdlibrary, which provides the same API ascompression.zstd, so that users can write code in the same way as with the standard library.
Addbackports.zstdas an install dependency when[compression]is specified. - Keep the existing
zstandardlibrary available during a migration period. - From a user perspective, the way parameters are passed in the options dictionary may change.
While the functionality is equivalent, the API differs, so existing dictionaries may not work without modification.- If only the file extension or the compression level is specified, no changes are needed (e.g.,
compression='zstd',compression={'method': 'zstd', 'level': 1}).
- If only the file extension or the compression level is specified, no changes are needed (e.g.,
Suggested migration steps
- Add an
'engine'key to the options dictionary, allowing'zstandard'or'compression.zstd'to be specified. - Use the specified library.
- Default to
'zstandard'if not specified. - Emit a warning that the default will change to
compression.zstdin the future. - On Python 3.13 and earlier, interpret
'compression.zstd'asbackports.zstd. - Change the default to
compression.zstdwhen'engine'is not specified. - Remove the
'engine'key and always usecompression.zstd.
Alternative Solutions
- Continue supporting both
compression.zstdandzstandard. It would leave the external dependency in place. - Convert the options dictionary internally without using an
'engine'key.
Some mapping can be inferred from keyword names, but the maintenance cost may not be worth it.
Additional Context
No response
Comment From: vinegh4
take