-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
The goal of this enhancement is to make the shelve module more usable by accepting custom types of pickler and unpickler.
Example
The lambda functions can not be pickled by Python's pickle module. So, for that reason the shelve library also can’t do that.
The shelve module was unable to handle this situation.
import shelve
with shelve.open("test_file") as sh:
squared = lambda x: x ** 2
sh['test_key'] = squaredWith the changes made here, the shelve module can easily overcome this issue.
import dill
import shelve
with shelve.open("test_file_2", pickler=dill.Pickler, unpickler=dill.Unpickler) as sh:
squared = lambda x: x ** 2
sh['test_key'] = squaredPrevious discussion
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement