[issue11299] Allow deepcopying paused generators

2017-02-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Antoine. copy.deepcopy() should be used with care since it recursively copies all referred data. In case of generators the data can be referred implicitly. Every global value cached in local variable, every passed argument, every nonlocal vari

[issue11299] Allow deepcopying paused generators

2013-12-08 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Unless I misunderstood things, and deepcopying a generator would imply > to also copy its whole source of data? deepcopying is "deep", and so would have to recursively deepcopy the generator's local variables... -- ___

[issue11299] Allow deepcopying paused generators

2013-12-08 Thread Bastien Montagne
Bastien Montagne added the comment: Yes, itertools.tee just keep in memory elements produced by the "most advanced" iterator, until the "least advanced" iterator consumes them. It may not be a big issue in most cases, but I can assure you that when you have to iter several times over a million

[issue11299] Allow deepcopying paused generators

2013-12-08 Thread Antoine Pitrou
Antoine Pitrou added the comment: > The issue here is copy.deepcopy will raise an exception whenever it > encounters a generator. We would like to do better here. > Unfortunately, using itertools.tee is not a solution here because it > does not preserve the type of the object. Indeed, itertools.

[issue11299] Allow deepcopying paused generators

2013-12-08 Thread Ram Rachum
Ram Rachum added the comment: "Instead of copy.deepcopy, why not call itertools.tee?" It's hard for me to give you a good answer because I submitted this ticket 2 years ago, and nowadays I don't have personal interest in it anymore. But, I think `itertools.tee` wouldn't have worked for me, bec

[issue11299] Allow deepcopying paused generators

2013-12-08 Thread Alexandre Vassalotti
Alexandre Vassalotti added the comment: The issue here is copy.deepcopy will raise an exception whenever it encounters a generator. We would like to do better here. Unfortunately, using itertools.tee is not a solution here because it does not preserve the type of the object. -- _

[issue11299] Allow deepcopying paused generators

2013-12-08 Thread Antoine Pitrou
Antoine Pitrou added the comment: Instead of copy.deepcopy, why not call itertools.tee? For the record, pickling a live generator implies pickling a frame object. We wouldn't be able to guarantee cross-version compatibility for such pickled objects. -- ___

[issue11299] Allow deepcopying paused generators

2013-12-08 Thread Bastien Montagne
Changes by Bastien Montagne : -- nosy: +mont29 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue11299] Allow deepcopying paused generators

2013-12-01 Thread Alexandre Vassalotti
Alexandre Vassalotti added the comment: Allowing generators to be deepcopied via their code object should be fine. -- stage: test needed -> needs patch title: Allow deepcopying and pickling paused generators -> Allow deepcopying paused generators versions: +Python 3.5 -Python 3.3 _