2 ms·
Good criticisms. (1) You can only pickle generators that generate the same sequence every time they are restarted. I don't know how you can persist state if y
by bravura 17y ago
Good criticisms.
(1) You can only pickle generators that generate the same sequence every time they are restarted.
I don't know how you can persist state if you do not make this assumption.
(2) All the work the generator did prior to pickling must be performed again on unpickling.
Something faster would be to use file.tell() to get the state and file.seek() to set the state. Since the "unpickling" is not a bottleneck, I didn't optimize this.