File extension conflicts with Python's .pkl #52

Closed
opened 2025-12-30 01:20:08 +01:00 by adam · 7 comments
Owner

Originally created by @bitnom on GitHub (Feb 11, 2024).

I'm sure you're aware the file extension .pkl has long been used by Python. Think of all the Python scripts and tooling out there which look for .pkl files. One consequence off the top of my head is that many .gitignore boilerplates contain *.pkl. There must be countless projects already referencing .pkl files.

Maybe add a fourth character before this thing spreads any further. I'm super curious what the rationale was for greenlighting a conflicting file-extension.

Originally created by @bitnom on GitHub (Feb 11, 2024). I'm sure you're aware the file extension .pkl has long been used by Python. Think of all the Python scripts and tooling out there which look for .pkl files. One consequence off the top of my head is that many .gitignore boilerplates contain `*.pkl`. There must be countless projects already referencing .pkl files. Maybe add a fourth character before this thing spreads any further. I'm super curious what the rationale was for greenlighting a conflicting file-extension.
adam closed this issue 2025-12-30 01:20:08 +01:00
Author
Owner

@cellomath commented on GitHub (Feb 12, 2024):

Per the Python Docs,

The pickle module is not secure. Only unpickle data you trust.
...
Safer serialization formats such as json may be more appropriate if you are processing untrusted data. See Comparison with json

Thus, any programs searching the filesystem for *.pkl python files are responsible for maintaining that they only load .pkl files they trust, and not this format's config files.

In the other case that the program is not responsible for managing the directory, you'll also get thrown a _pickle.UnpicklingError: Memo value not found at [index] if attempting to unpickle a .pkl config file, which can be handled by the program.

Are you thinking of a project in particular for which this file extension conflict might cause an issue?

@cellomath commented on GitHub (Feb 12, 2024): Per the [Python Docs](https://docs.python.org/3/library/pickle.html), > The pickle module is not secure. Only unpickle data you trust. > ... > Safer serialization formats such as [json](https://docs.python.org/3/library/json.html#module-json) may be more appropriate if you are processing untrusted data. See [Comparison with json](https://docs.python.org/3/library/pickle.html#comparison-with-json) Thus, any programs searching the filesystem for `*.pkl` python files are responsible for maintaining that they only load `.pkl` files they trust, and not this format's config files. In the other case that the program is not responsible for managing the directory, you'll also get thrown a `_pickle.UnpicklingError: Memo value not found at [index]` if attempting to unpickle a .pkl config file, which can be handled by the program. Are you thinking of a project in particular for which this file extension conflict might cause an issue?
Author
Owner

@bioball commented on GitHub (Feb 14, 2024):

As far as I'm aware, Python's pickle doesn't have an official file extension. Python's authors themselves seem to have moved on from .pkl, and now prefer .pickle: https://stackoverflow.com/questions/40433474/preferred-or-most-common-file-extension-for-a-python-pickle

For projects that look to use both Pkl and python pickle, maybe it's best to use .pickle as the filename for python pickle files.

@bioball commented on GitHub (Feb 14, 2024): As far as I'm aware, Python's pickle doesn't have an official file extension. Python's authors themselves seem to have moved on from `.pkl`, and now prefer `.pickle`: https://stackoverflow.com/questions/40433474/preferred-or-most-common-file-extension-for-a-python-pickle For projects that look to use both Pkl and python pickle, maybe it's best to use `.pickle` as the filename for python pickle files.
Author
Owner

@chrisvander commented on GitHub (Feb 14, 2024):

I don't think this is relevant. Pickled files have long been saved on developer preference; there's no particular reason that they have to use .pkl or .pickle.

@chrisvander commented on GitHub (Feb 14, 2024): I don't think this is relevant. Pickled files have long been saved on developer preference; there's no particular reason that they have to use `.pkl` or `.pickle`.
Author
Owner

@moritztim commented on GitHub (Feb 14, 2024):

This should be closed as "not planned"

@moritztim commented on GitHub (Feb 14, 2024): This should be closed as "not planned"
Author
Owner

@bioball commented on GitHub (Feb 14, 2024):

Agree; closing this.

@bioball commented on GitHub (Feb 14, 2024): Agree; closing this.
Author
Owner

@akshitsingh23 commented on GitHub (Jul 7, 2024):

I used pickle to save my model for a project. I stored the visualizer file also in pickle format. But when I am integrating it with Flask and using them to generate output. It is giving only 1 output.
For the frontend I am using react.
I have tried downloading model.pkl from colab but still getting wrong output.
Can you please help me.

@akshitsingh23 commented on GitHub (Jul 7, 2024): I used pickle to save my model for a project. I stored the visualizer file also in pickle format. But when I am integrating it with Flask and using them to generate output. It is giving only 1 output. For the frontend I am using react. I have tried downloading model.pkl from colab but still getting wrong output. Can you please help me.
Author
Owner

@moritztim commented on GitHub (Jul 8, 2024):

I used pickle to save my model for a project. I stored the visualizer file also in pickle format. But when I am integrating it with Flask and using them to generate output. It is giving only 1 output. For the frontend I am using react. I have tried downloading model.pkl from colab but still getting wrong output. Can you please help me.

@akshitsingh23 This is the comment section of an issue in a different project that uses the same file extension. This repository has nothing to do with python's pickle library. You could try directing your question at StackOverflow.

@moritztim commented on GitHub (Jul 8, 2024): > I used pickle to save my model for a project. I stored the visualizer file also in pickle format. But when I am integrating it with Flask and using them to generate output. It is giving only 1 output. For the frontend I am using react. I have tried downloading model.pkl from colab but still getting wrong output. Can you please help me. @akshitsingh23 This is the comment section of an issue in a different project that uses the same file extension. This repository has nothing to do with python's pickle library. You could try directing your question at [StackOverflow](https://stackoverflow.com/).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#52