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

2014-04-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, then I've committed to 2.7 too. Thank you very much for contributing! -- status: open -> closed ___ Python tracker ___ _

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

2014-04-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 8ee76e1b5aa6 by Antoine Pitrou in branch '2.7': Issue #21321: itertools.islice() now releases the reference to the source iterator when the slice is exhausted. http://hg.python.org/cpython/rev/8ee76e1b5aa6 -- __

[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 __

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

2014-04-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Patch committed, thank you! If you want to provide a patch for 2.7, please say so, otherwise I'll close the issue. -- resolution: -> fixed stage: -> resolved ___ Python tracker

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

2014-04-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset b795105db23a by Antoine Pitrou in branch '3.4': Issue #21321: itertools.islice() now releases the reference to the source iterator when the slice is exhausted. http://hg.python.org/cpython/rev/b795105db23a New changeset a627b3e3c9c8 by Antoine Pitr

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

2014-04-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: For the record, checks such as: self.assertEqual(wr() is None, False) are better written: self.assertIsNotNone(wr()) No need to upload a new patch, I'm gonna make the change while committing :-) -- ___

[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 exha

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

2014-04-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Thanks. Could you also add a test for the islice_reduce additions? Or is it already tested? I suspect there's a reference leak there: after calling PyObject_GetIter, you should always Py_DECREF(empty_list). Also, with the "O" code, Py_BuildValue will take a new

[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 : Added file: http://bugs.python.org/file35086/issue21321_2.7_e3217efa6edd_4.diff ___ Python tracker ___ ___ Python

[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 : Added file: http://bugs.python.org/file35087/issue21321_3.4_8c8315bac6a8_4.diff ___ Python tracker ___ ___ Python

[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, 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 straight

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

2014-04-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: (note I haven't looked at the C part of the patch) -- ___ Python tracker ___ ___ Python-bugs-list ma

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

2014-04-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: Anton, the test is wrong: it is taking a reference to the iterable object (the list), not the iterator. To check the reference to the original iterator is released, something like this would work: >>> import itertools, weakref >>> it = (x for x in (1, 2)) >>>

[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 : Added file: http://bugs.python.org/file35077/issue21321_3.4_8c8315bac6a8_3.diff ___ Python tracker ___ ___ Python

[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() af

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

2014-04-25 Thread Antoine Pitrou
Antoine Pitrou added the comment: Haven't reviewed the patch, but you should definitely add a unit test for the bugfix. -- ___ Python tracker ___ ___

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

2014-04-25 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- versions: +Python 3.5 -Python 3.1, Python 3.2, Python 3.3 ___ Python tracker ___ ___ Python-bugs-list m

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

2014-04-22 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +pitrou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[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 tr

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

2014-04-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: The ref-counts in the islice_reduce code don't look to be correct at first glance. -- assignee: -> rhettinger ___ Python tracker ___ __

[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

[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)