This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make _tuplegetter objects serializable
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: llllllllll, rhettinger
Priority: normal Keywords: patch

Created on 2019-02-21 18:44 by llllllllll, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11981 merged llllllllll, 2019-02-21 18:46
Messages (4)
msg336251 - (view) Author: Joe Jevnik (llllllllll) * Date: 2019-02-21 18:44
The new _tuplegetter objects for accessing fields of a namedtuple are no longer serializable with pickle. Cloudpickle, a library which provides extensions to pickle to facilitate distributed computing in Python, depended on being able to pickle the members of namedtuple classes. While property isn't serializable, cloudpickle has support for properties allowing us to serialize the old property(itemgetter) members.

The attached PR adds a __reduce__ method to _tuplegetter objects which will allow serialization without special support. Another option would be to expose `index` as a read-only attribute, allowing cloudpickle or other libraries to provide the pickle implementation as a third-party library.
msg336258 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-02-21 20:59
Thanks for noticing this.  We really should have stuck with the original plan of subclassing property().
msg336259 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-02-21 21:00
New changeset f36f89257b30e0bf88e8aaff6da14a9a96f57b9e by Raymond Hettinger (Joe Jevnik) in branch 'master':
bpo-36068: Make _tuplegetter objects serializable (GH-11981)
https://github.com/python/cpython/commit/f36f89257b30e0bf88e8aaff6da14a9a96f57b9e
msg336260 - (view) Author: Joe Jevnik (llllllllll) * Date: 2019-02-21 21:11
Thank you for reviewing this so quickly!
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80249
2019-02-21 21:11:29llllllllllsetmessages: + msg336260
2019-02-21 21:01:12rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-02-21 21:00:43rhettingersetmessages: + msg336259
2019-02-21 20:59:55rhettingersetassignee: rhettinger
messages: + msg336258
2019-02-21 18:51:10xtreaksetnosy: + rhettinger
2019-02-21 18:46:07llllllllllsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12006
2019-02-21 18:44:13llllllllllcreate