[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-29 Thread Anton Afanasyev
Anton Afanasyev added the comment: Hi Antoine, my test works for me. It can be either a = [1, 2, 3] or a = iter([1, 2, 3]) , no matter: both objects will be +1 referenced after taking b = islice(a, 1) . My test failed without patch and passed with one. But your test is more straightforward

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-29 Thread Anton Afanasyev
Changes by Anton Afanasyev fun@gmail.com: Added file: http://bugs.python.org/file35087/issue21321_3.4_8c8315bac6a8_4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21321

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-29 Thread Anton Afanasyev
Changes by Anton Afanasyev fun@gmail.com: Added file: http://bugs.python.org/file35086/issue21321_2.7_e3217efa6edd_4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21321

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-29 Thread Anton Afanasyev
Anton Afanasyev added the comment: Hi Antoine, oops you are right about leaks: fixed them in new attached patch. As for testing changes in reduce(): they are already covered by self.pickletest(islice(range(100), *args)). Function pickletest() covers case for pickle dumping/loading of exhausted

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-29 Thread Anton Afanasyev
Anton Afanasyev added the comment: Antoine, not sure about 2.7. The issue first arose for me at Python 2.7, so I would prefer issue21321_2.7_e3217efa6edd_4.diff patch be applied. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-28 Thread Anton Afanasyev
Anton Afanasyev added the comment: Hi Antoine, I have no found a way to check resource usage in test infrastructure and I don't think it could be done carefully. The only method I found to test issue is straightforward: just to check source iterator is not referenced from itertools.islice

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-28 Thread Anton Afanasyev
Changes by Anton Afanasyev fun@gmail.com: Added file: http://bugs.python.org/file35077/issue21321_3.4_8c8315bac6a8_3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21321

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-22 Thread Anton Afanasyev
Anton Afanasyev added the comment: Hi Raymond, do you mean allocation exceptions handling should be more accurate? Attaching fixed version for 3.4 branch. -- Added file: http://bugs.python.org/file35003/issue21321_3.4_8c8315bac6a8_2.diff ___ Python

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-21 Thread Anton Afanasyev
New submission from Anton Afanasyev: This issue results in redundant memory consumption for e.g. in this case: from itertools import * def test_islice(): items, lookahead = tee(repeat(1, int(1e9))) lookahead = islice(lookahead, 10

[issue21321] itertools.islice() doesn't release reference to the source iterator when the slice is exhausted

2014-04-21 Thread Anton Afanasyev
Anton Afanasyev added the comment: Added patch for 2.7 version (no need to change '__reduce__()' method since it's not implemented). -- Added file: http://bugs.python.org/file34991/issue21321_2.7_e3217efa6edd.diff ___ Python tracker rep