Improve the implementation of itertools.product()
* Fix-up issues pointed-out by Neal Norwitz.
* Add extensive comments.
* The lz->result variable is now a tuple instead of a list.
* Use fast macro getitem/setitem calls so most code is in-line.
* Re-use the result tuple if available (modify in-place instead of copy).
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index e65bba7..f5dd069 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -274,6 +274,9 @@
args = map(iter, args)
self.assertEqual(len(list(product(*args))), n)
+ # Test implementation detail: tuple re-use
+ self.assertEqual(len(set(map(id, product('abc', 'def')))), 1)
+ self.assertNotEqual(len(set(map(id, list(product('abc', 'def'))))), 1)
def test_repeat(self):
self.assertEqual(zip(xrange(3),repeat('a')),