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.zstd
internally. - For Python 3.13 and earlier, use the
backports.zstd
library, which provides the same API ascompression.zstd
, so that users can write code in the same way as with the standard library.
Addbackports.zstd
as an install dependency when[compression]
is specified. - Keep the existing
zstandard
library 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.zstd
in the future. - On Python 3.13 and earlier, interpret
'compression.zstd'
asbackports.zstd
. - Change the default to
compression.zstd
when'engine'
is not specified. - Remove the
'engine'
key and always usecompression.zstd
.
Alternative Solutions
- Continue supporting both
compression.zstd
andzstandard
. 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