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 slices pickable
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: connelly, rhettinger, sdementen
Priority: normal Keywords:

Created on 2005-04-28 13:44 by sdementen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg54499 - (view) Author: Sebastien de Menten (sdementen) Date: 2005-04-28 13:44
As suggested  by the summary, provide pickability of 
slices by default.
Currently one has to use copy_reg module to register 
slices as pickables.
msg54500 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-04-30 12:32
Logged In: YES 
user_id=80475

Use cases?
msg54501 - (view) Author: Sebastien de Menten (sdementen) Date: 2005-04-30 18:02
Logged In: YES 
user_id=820079

Use case for pickable slices. 
Let A be a numeric array of size M x N. We want to consider 
sub-arrays in this array like A[:4, :] (the first 4 lines of the 
array). 
If we want to store both the array and the information of 
sub-arrays structures, we need to store slices (we can also 
store start/end indices of the array ... but this is call a slice 
so it would be better to have pickable slices). 
 
In fact, whenever one wants to write generic algorithm 
working on "sublist of lists" or "subarrays of arrays" or 
"sub-items of collection of items", it is nicer to use slice 
objects explicitly and so store them also explicitly. 
 
msg54502 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-06-03 00:50
Logged In: YES 
user_id=80475

Okay, sounds reasonable.  Will implement when I have time.
msg54503 - (view) Author: Connelly (connelly) Date: 2006-07-16 18:55
Logged In: YES 
user_id=1039782

Additional use case: I needed picklable slices when logging method calls to a 
database:  __setitem__(self, i, x) could not be logged because the database 
module attempted to pickle objects such as ('__setitem__', slice(1, 2, 3), []).

For other Python users who have run into this problem: the code needed to 
make slices picklable by copy_reg is available at:

  http://mail.python.org/pipermail/python-list/2004-November/
248988.html
msg54504 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-04-11 18:41
Done.  See revision 54760.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 41919
2005-04-28 13:44:34sdementencreate