You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1137 lines
32 KiB

36 years ago
36 years ago
Patch by Charles G Waldman to avoid a sneaky memory leak in _PyTuple_Resize(). In addition, a change suggested by Jeremy Hylton to limit the size of the free lists is also merged into this patch. Charles wrote initially: """ Test Case: run the following code: class Nothing: def __len__(self): return 5 def __getitem__(self, i): if i < 3: return i else: raise IndexError, i def g(a,*b,**c): return for x in xrange(1000000): g(*Nothing()) and watch Python's memory use go up and up. Diagnosis: The analysis begins with the call to PySequence_Tuple at line 1641 in ceval.c - the argument to g is seen to be a sequence but not a tuple, so it needs to be converted from an abstract sequence to a concrete tuple. PySequence_Tuple starts off by creating a new tuple of length 5 (line 1122 in abstract.c). Then at line 1149, since only 3 elements were assigned, _PyTuple_Resize is called to make the 5-tuple into a 3-tuple. When we're all done the 3-tuple is decrefed, but rather than being freed it is placed on the free_tuples cache. The basic problem is that the 3-tuples are being added to the cache but never picked up again, since _PyTuple_Resize doesn't make use of the free_tuples cache. If you are resizing a 5-tuple to a 3-tuple and there is already a 3-tuple in free_tuples[3], instead of using this tuple, _PyTuple_Resize will realloc the 5-tuple to a 3-tuple. It would more efficient to use the existing 3-tuple and cache the 5-tuple. By making _PyTuple_Resize aware of the free_tuples (just as PyTuple_New), we not only save a few calls to realloc, but also prevent this misbehavior whereby tuples are being added to the free_tuples list but never properly "recycled". """ And later: """ This patch replaces my submission of Sun, 16 Apr and addresses Jeremy Hylton's suggestions that we also limit the size of the free tuple list. I chose 2000 as the maximum number of tuples of any particular size to save. There was also a problem with the previous version of this patch causing a core dump if Python was built with Py_TRACE_REFS. This is fixed in the below version of the patch, which uses tupledealloc instead of _Py_Dealloc. """
26 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
Patch by Charles G Waldman to avoid a sneaky memory leak in _PyTuple_Resize(). In addition, a change suggested by Jeremy Hylton to limit the size of the free lists is also merged into this patch. Charles wrote initially: """ Test Case: run the following code: class Nothing: def __len__(self): return 5 def __getitem__(self, i): if i < 3: return i else: raise IndexError, i def g(a,*b,**c): return for x in xrange(1000000): g(*Nothing()) and watch Python's memory use go up and up. Diagnosis: The analysis begins with the call to PySequence_Tuple at line 1641 in ceval.c - the argument to g is seen to be a sequence but not a tuple, so it needs to be converted from an abstract sequence to a concrete tuple. PySequence_Tuple starts off by creating a new tuple of length 5 (line 1122 in abstract.c). Then at line 1149, since only 3 elements were assigned, _PyTuple_Resize is called to make the 5-tuple into a 3-tuple. When we're all done the 3-tuple is decrefed, but rather than being freed it is placed on the free_tuples cache. The basic problem is that the 3-tuples are being added to the cache but never picked up again, since _PyTuple_Resize doesn't make use of the free_tuples cache. If you are resizing a 5-tuple to a 3-tuple and there is already a 3-tuple in free_tuples[3], instead of using this tuple, _PyTuple_Resize will realloc the 5-tuple to a 3-tuple. It would more efficient to use the existing 3-tuple and cache the 5-tuple. By making _PyTuple_Resize aware of the free_tuples (just as PyTuple_New), we not only save a few calls to realloc, but also prevent this misbehavior whereby tuples are being added to the free_tuples list but never properly "recycled". """ And later: """ This patch replaces my submission of Sun, 16 Apr and addresses Jeremy Hylton's suggestions that we also limit the size of the free tuple list. I chose 2000 as the maximum number of tuples of any particular size to save. There was also a problem with the previous version of this patch causing a core dump if Python was built with Py_TRACE_REFS. This is fixed in the below version of the patch, which uses tupledealloc instead of _Py_Dealloc. """
26 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
36 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
36 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines Add diagnostic message to help figure-out why SocketServer tests occasionally crash when trying to remove a pid that in not in the activechildren list. ........ r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line Add fixed-point examples to the decimal FAQ ........ r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Improve rst markup ........ r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line Show how to remove exponents. ........ r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup. ........ r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. ........ r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line Simplify moneyfmt() recipe. ........ r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup ........ r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line No need to register subclass of ABCs. ........ r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line Try to correct a markup error that does hide the following paragraph. ........ r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 ........ r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. ........ r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ Thanks to Thomas Herve for the fix. ........ r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. ........ r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines Two new functions: * place_summary_first copies the regrtest summary to the front of the file making it easier to scan quickly for problems. * count_failures gets the actual count of the number of failing tests, not just a 1 (some failures) or 0 (no failures). ........ r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line Update example to match the current syntax. ........ r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines Issue #2115: __slot__ attributes setting was 10x slower. Also correct a possible crash using ABCs. This change is exactly the same as an optimisation done 5 years ago, but on slot *access*: http://svn.python.org/view?view=rev&rev=28297 ........ r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines Temporarily let these tests pass ........ r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. ........ r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines Configured selection highlighting colors were ignored; updating highlighting in the config dialog would cause non-Python files to be colored as if they were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. ........ r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line Increase debugging to investige failing tests on some build bots ........ r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line Small adjustments for test compact freelist test. It's no passing on Windows as well. ........ r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines Correct quotes in NEWS file ........ r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines #1750076: Debugger did not step on every iteration of a while statement. The mapping between bytecode offsets and source lines (lnotab) did not contain an entry for the beginning of the loop. Now it does, and the lnotab can be a bit larger: in particular, several statements on the same line generate several entries. However, this does not bother the settrace function, which will trigger only one 'line' event. The lnotab seems to be exactly the same as with python2.4. ........ r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines Change r60575 broke test_compile: there is no need to emit co_lnotab item when both offsets are zeros. ........ r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line sync with most recent version from python-mode sf project ........ r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines Issue #2004: Use mode 0700 for temporary directories and default permissions for missing directories. (will backport to 2.5) ........ r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines Convert external links to internal links. Fixes #2010. ........ r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines Keep distutils Python 2.1 compatible (or even Python 2.4 in this case). ........ r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines Update PEP URL. (This code is duplicated between pydoc and DocXMLRPCServer; maybe it should be refactored as a GHOP project.) 2.5.2 backport candidate. ........ r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines In the experimental 'Scanner' feature, the group count was set wrong. ........ r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines Issue 1951. Converts wave test cases to unittest. ........ r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines Actually run the test. ........ r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines correct object name ........ r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines * Use the same code to profile for test_profile and test_cprofile. * Convert both to unittest. * Use the same unit testing code. * Include the expected output in both test files. * Make it possible to regenerate the expected output by running the file as a script with an '-r' argument. ........ r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line Sync-up with Py3k work. ........ r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line Limit free list of method and builtin function objects to 256 entries each. ........ r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines Unified naming convention for free lists and their limits. All free lists in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines Add diagnostic message to help figure-out why SocketServer tests occasionally crash when trying to remove a pid that in not in the activechildren list. ........ r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line Add fixed-point examples to the decimal FAQ ........ r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Improve rst markup ........ r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line Show how to remove exponents. ........ r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup. ........ r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. ........ r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line Simplify moneyfmt() recipe. ........ r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup ........ r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line No need to register subclass of ABCs. ........ r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line Try to correct a markup error that does hide the following paragraph. ........ r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 ........ r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. ........ r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ Thanks to Thomas Herve for the fix. ........ r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. ........ r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines Two new functions: * place_summary_first copies the regrtest summary to the front of the file making it easier to scan quickly for problems. * count_failures gets the actual count of the number of failing tests, not just a 1 (some failures) or 0 (no failures). ........ r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line Update example to match the current syntax. ........ r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines Issue #2115: __slot__ attributes setting was 10x slower. Also correct a possible crash using ABCs. This change is exactly the same as an optimisation done 5 years ago, but on slot *access*: http://svn.python.org/view?view=rev&rev=28297 ........ r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines Temporarily let these tests pass ........ r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. ........ r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines Configured selection highlighting colors were ignored; updating highlighting in the config dialog would cause non-Python files to be colored as if they were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. ........ r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines Add diagnostic message to help figure-out why SocketServer tests occasionally crash when trying to remove a pid that in not in the activechildren list. ........ r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line Add fixed-point examples to the decimal FAQ ........ r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Improve rst markup ........ r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line Show how to remove exponents. ........ r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup. ........ r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. ........ r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line Simplify moneyfmt() recipe. ........ r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup ........ r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line No need to register subclass of ABCs. ........ r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line Try to correct a markup error that does hide the following paragraph. ........ r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 ........ r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. ........ r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ Thanks to Thomas Herve for the fix. ........ r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. ........ r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines Two new functions: * place_summary_first copies the regrtest summary to the front of the file making it easier to scan quickly for problems. * count_failures gets the actual count of the number of failing tests, not just a 1 (some failures) or 0 (no failures). ........ r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line Update example to match the current syntax. ........ r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines Issue #2115: __slot__ attributes setting was 10x slower. Also correct a possible crash using ABCs. This change is exactly the same as an optimisation done 5 years ago, but on slot *access*: http://svn.python.org/view?view=rev&rev=28297 ........ r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines Temporarily let these tests pass ........ r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. ........ r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines Configured selection highlighting colors were ignored; updating highlighting in the config dialog would cause non-Python files to be colored as if they were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. ........ r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines Add diagnostic message to help figure-out why SocketServer tests occasionally crash when trying to remove a pid that in not in the activechildren list. ........ r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line Add fixed-point examples to the decimal FAQ ........ r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Improve rst markup ........ r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line Show how to remove exponents. ........ r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup. ........ r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. ........ r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line Simplify moneyfmt() recipe. ........ r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup ........ r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line No need to register subclass of ABCs. ........ r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line Try to correct a markup error that does hide the following paragraph. ........ r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 ........ r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. ........ r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ Thanks to Thomas Herve for the fix. ........ r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. ........ r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines Two new functions: * place_summary_first copies the regrtest summary to the front of the file making it easier to scan quickly for problems. * count_failures gets the actual count of the number of failing tests, not just a 1 (some failures) or 0 (no failures). ........ r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line Update example to match the current syntax. ........ r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines Issue #2115: __slot__ attributes setting was 10x slower. Also correct a possible crash using ABCs. This change is exactly the same as an optimisation done 5 years ago, but on slot *access*: http://svn.python.org/view?view=rev&rev=28297 ........ r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines Temporarily let these tests pass ........ r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. ........ r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines Configured selection highlighting colors were ignored; updating highlighting in the config dialog would cause non-Python files to be colored as if they were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. ........ r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines Add diagnostic message to help figure-out why SocketServer tests occasionally crash when trying to remove a pid that in not in the activechildren list. ........ r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line Add fixed-point examples to the decimal FAQ ........ r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Improve rst markup ........ r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line Show how to remove exponents. ........ r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup. ........ r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. ........ r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line Simplify moneyfmt() recipe. ........ r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup ........ r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line No need to register subclass of ABCs. ........ r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line Try to correct a markup error that does hide the following paragraph. ........ r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 ........ r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. ........ r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ Thanks to Thomas Herve for the fix. ........ r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. ........ r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines Two new functions: * place_summary_first copies the regrtest summary to the front of the file making it easier to scan quickly for problems. * count_failures gets the actual count of the number of failing tests, not just a 1 (some failures) or 0 (no failures). ........ r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line Update example to match the current syntax. ........ r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines Issue #2115: __slot__ attributes setting was 10x slower. Also correct a possible crash using ABCs. This change is exactly the same as an optimisation done 5 years ago, but on slot *access*: http://svn.python.org/view?view=rev&rev=28297 ........ r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines Temporarily let these tests pass ........ r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. ........ r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines Configured selection highlighting colors were ignored; updating highlighting in the config dialog would cause non-Python files to be colored as if they were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. ........ r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60845 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60790 | raymond.hettinger | 2008-02-14 10:32:45 +0100 (Thu, 14 Feb 2008) | 4 lines Add diagnostic message to help figure-out why SocketServer tests occasionally crash when trying to remove a pid that in not in the activechildren list. ........ r60791 | raymond.hettinger | 2008-02-14 11:46:57 +0100 (Thu, 14 Feb 2008) | 1 line Add fixed-point examples to the decimal FAQ ........ r60792 | raymond.hettinger | 2008-02-14 12:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Improve rst markup ........ r60794 | raymond.hettinger | 2008-02-14 12:57:25 +0100 (Thu, 14 Feb 2008) | 1 line Show how to remove exponents. ........ r60795 | raymond.hettinger | 2008-02-14 13:05:42 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup. ........ r60797 | christian.heimes | 2008-02-14 13:47:33 +0100 (Thu, 14 Feb 2008) | 1 line Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation. ........ r60798 | raymond.hettinger | 2008-02-14 13:49:37 +0100 (Thu, 14 Feb 2008) | 1 line Simplify moneyfmt() recipe. ........ r60810 | raymond.hettinger | 2008-02-14 20:02:39 +0100 (Thu, 14 Feb 2008) | 1 line Fix markup ........ r60811 | raymond.hettinger | 2008-02-14 20:30:30 +0100 (Thu, 14 Feb 2008) | 1 line No need to register subclass of ABCs. ........ r60814 | thomas.heller | 2008-02-14 22:00:28 +0100 (Thu, 14 Feb 2008) | 1 line Try to correct a markup error that does hide the following paragraph. ........ r60822 | christian.heimes | 2008-02-14 23:40:11 +0100 (Thu, 14 Feb 2008) | 1 line Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115 ........ r60827 | christian.heimes | 2008-02-15 07:57:08 +0100 (Fri, 15 Feb 2008) | 1 line Fixed repr() and str() of complex numbers. Complex suffered from the same problem as floats but I forgot to test and fix them. ........ r60830 | christian.heimes | 2008-02-15 09:20:11 +0100 (Fri, 15 Feb 2008) | 2 lines Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ Thanks to Thomas Herve for the fix. ........ r60835 | eric.smith | 2008-02-15 13:14:32 +0100 (Fri, 15 Feb 2008) | 1 line In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long. ........ r60837 | skip.montanaro | 2008-02-15 20:03:59 +0100 (Fri, 15 Feb 2008) | 8 lines Two new functions: * place_summary_first copies the regrtest summary to the front of the file making it easier to scan quickly for problems. * count_failures gets the actual count of the number of failing tests, not just a 1 (some failures) or 0 (no failures). ........ r60840 | raymond.hettinger | 2008-02-15 22:21:25 +0100 (Fri, 15 Feb 2008) | 1 line Update example to match the current syntax. ........ r60841 | amaury.forgeotdarc | 2008-02-15 22:22:45 +0100 (Fri, 15 Feb 2008) | 8 lines Issue #2115: __slot__ attributes setting was 10x slower. Also correct a possible crash using ABCs. This change is exactly the same as an optimisation done 5 years ago, but on slot *access*: http://svn.python.org/view?view=rev&rev=28297 ........ r60842 | amaury.forgeotdarc | 2008-02-15 22:27:44 +0100 (Fri, 15 Feb 2008) | 2 lines Temporarily let these tests pass ........ r60843 | kurt.kaiser | 2008-02-15 22:56:36 +0100 (Fri, 15 Feb 2008) | 2 lines ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat. ........ r60844 | kurt.kaiser | 2008-02-15 23:25:09 +0100 (Fri, 15 Feb 2008) | 4 lines Configured selection highlighting colors were ignored; updating highlighting in the config dialog would cause non-Python files to be colored as if they were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat. ........ r60845 | amaury.forgeotdarc | 2008-02-15 23:44:20 +0100 (Fri, 15 Feb 2008) | 9 lines Re-enable tests, they were failing since gc.collect() clears the various freelists. They still remain fragile. For example, a call to assertEqual currently does not make any allocation (which surprised me at first). But this can change when gc.collect also deletes the numerous "zombie frames" attached to each function. ........
18 years ago
  1. /* Tuple object implementation */
  2. #include "Python.h"
  3. #include "pycore_abstract.h" // _PyIndex_Check()
  4. #include "pycore_object.h"
  5. #include "pycore_pystate.h"
  6. #include "pycore_accu.h"
  7. /*[clinic input]
  8. class tuple "PyTupleObject *" "&PyTuple_Type"
  9. [clinic start generated code]*/
  10. /*[clinic end generated code: output=da39a3ee5e6b4b0d input=f051ba3cfdf9a189]*/
  11. #include "clinic/tupleobject.c.h"
  12. /* Speed optimization to avoid frequent malloc/free of small tuples */
  13. #ifndef PyTuple_MAXSAVESIZE
  14. #define PyTuple_MAXSAVESIZE 20 /* Largest tuple to save on free list */
  15. #endif
  16. #ifndef PyTuple_MAXFREELIST
  17. #define PyTuple_MAXFREELIST 2000 /* Maximum number of tuples of each size to save */
  18. #endif
  19. #if PyTuple_MAXSAVESIZE > 0
  20. /* Entries 1 up to PyTuple_MAXSAVESIZE are free lists, entry 0 is the empty
  21. tuple () of which at most one instance will be allocated.
  22. */
  23. static PyTupleObject *free_list[PyTuple_MAXSAVESIZE];
  24. static int numfree[PyTuple_MAXSAVESIZE];
  25. #endif
  26. static inline void
  27. tuple_gc_track(PyTupleObject *op)
  28. {
  29. _PyObject_GC_TRACK(op);
  30. }
  31. /* Print summary info about the state of the optimized allocator */
  32. void
  33. _PyTuple_DebugMallocStats(FILE *out)
  34. {
  35. #if PyTuple_MAXSAVESIZE > 0
  36. int i;
  37. char buf[128];
  38. for (i = 1; i < PyTuple_MAXSAVESIZE; i++) {
  39. PyOS_snprintf(buf, sizeof(buf),
  40. "free %d-sized PyTupleObject", i);
  41. _PyDebugAllocatorStats(out,
  42. buf,
  43. numfree[i], _PyObject_VAR_SIZE(&PyTuple_Type, i));
  44. }
  45. #endif
  46. }
  47. /* Allocate an uninitialized tuple object. Before making it public following
  48. steps must be done:
  49. - initialize its items
  50. - call tuple_gc_track() on it
  51. Because the empty tuple is always reused and it's already tracked by GC,
  52. this function must not be called with size == 0 (unless from PyTuple_New()
  53. which wraps this function).
  54. */
  55. static PyTupleObject *
  56. tuple_alloc(Py_ssize_t size)
  57. {
  58. PyTupleObject *op;
  59. if (size < 0) {
  60. PyErr_BadInternalCall();
  61. return NULL;
  62. }
  63. #if PyTuple_MAXSAVESIZE > 0
  64. if (size < PyTuple_MAXSAVESIZE && (op = free_list[size]) != NULL) {
  65. assert(size != 0);
  66. free_list[size] = (PyTupleObject *) op->ob_item[0];
  67. numfree[size]--;
  68. /* Inline PyObject_InitVar */
  69. #ifdef Py_TRACE_REFS
  70. Py_SIZE(op) = size;
  71. Py_TYPE(op) = &PyTuple_Type;
  72. #endif
  73. _Py_NewReference((PyObject *)op);
  74. }
  75. else
  76. #endif
  77. {
  78. /* Check for overflow */
  79. if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - (sizeof(PyTupleObject) -
  80. sizeof(PyObject *))) / sizeof(PyObject *)) {
  81. return (PyTupleObject *)PyErr_NoMemory();
  82. }
  83. op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
  84. if (op == NULL)
  85. return NULL;
  86. }
  87. return op;
  88. }
  89. PyObject *
  90. PyTuple_New(Py_ssize_t size)
  91. {
  92. PyTupleObject *op;
  93. #if PyTuple_MAXSAVESIZE > 0
  94. if (size == 0 && free_list[0]) {
  95. op = free_list[0];
  96. Py_INCREF(op);
  97. return (PyObject *) op;
  98. }
  99. #endif
  100. op = tuple_alloc(size);
  101. if (op == NULL) {
  102. return NULL;
  103. }
  104. for (Py_ssize_t i = 0; i < size; i++) {
  105. op->ob_item[i] = NULL;
  106. }
  107. #if PyTuple_MAXSAVESIZE > 0
  108. if (size == 0) {
  109. free_list[0] = op;
  110. ++numfree[0];
  111. Py_INCREF(op); /* extra INCREF so that this is never freed */
  112. }
  113. #endif
  114. tuple_gc_track(op);
  115. return (PyObject *) op;
  116. }
  117. Py_ssize_t
  118. PyTuple_Size(PyObject *op)
  119. {
  120. if (!PyTuple_Check(op)) {
  121. PyErr_BadInternalCall();
  122. return -1;
  123. }
  124. else
  125. return Py_SIZE(op);
  126. }
  127. PyObject *
  128. PyTuple_GetItem(PyObject *op, Py_ssize_t i)
  129. {
  130. if (!PyTuple_Check(op)) {
  131. PyErr_BadInternalCall();
  132. return NULL;
  133. }
  134. if (i < 0 || i >= Py_SIZE(op)) {
  135. PyErr_SetString(PyExc_IndexError, "tuple index out of range");
  136. return NULL;
  137. }
  138. return ((PyTupleObject *)op) -> ob_item[i];
  139. }
  140. int
  141. PyTuple_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem)
  142. {
  143. PyObject **p;
  144. if (!PyTuple_Check(op) || Py_REFCNT(op) != 1) {
  145. Py_XDECREF(newitem);
  146. PyErr_BadInternalCall();
  147. return -1;
  148. }
  149. if (i < 0 || i >= Py_SIZE(op)) {
  150. Py_XDECREF(newitem);
  151. PyErr_SetString(PyExc_IndexError,
  152. "tuple assignment index out of range");
  153. return -1;
  154. }
  155. p = ((PyTupleObject *)op) -> ob_item + i;
  156. Py_XSETREF(*p, newitem);
  157. return 0;
  158. }
  159. void
  160. _PyTuple_MaybeUntrack(PyObject *op)
  161. {
  162. PyTupleObject *t;
  163. Py_ssize_t i, n;
  164. if (!PyTuple_CheckExact(op) || !_PyObject_GC_IS_TRACKED(op))
  165. return;
  166. t = (PyTupleObject *) op;
  167. n = Py_SIZE(t);
  168. for (i = 0; i < n; i++) {
  169. PyObject *elt = PyTuple_GET_ITEM(t, i);
  170. /* Tuple with NULL elements aren't
  171. fully constructed, don't untrack
  172. them yet. */
  173. if (!elt ||
  174. _PyObject_GC_MAY_BE_TRACKED(elt))
  175. return;
  176. }
  177. _PyObject_GC_UNTRACK(op);
  178. }
  179. PyObject *
  180. PyTuple_Pack(Py_ssize_t n, ...)
  181. {
  182. Py_ssize_t i;
  183. PyObject *o;
  184. PyObject **items;
  185. va_list vargs;
  186. if (n == 0) {
  187. return PyTuple_New(0);
  188. }
  189. va_start(vargs, n);
  190. PyTupleObject *result = tuple_alloc(n);
  191. if (result == NULL) {
  192. va_end(vargs);
  193. return NULL;
  194. }
  195. items = result->ob_item;
  196. for (i = 0; i < n; i++) {
  197. o = va_arg(vargs, PyObject *);
  198. Py_INCREF(o);
  199. items[i] = o;
  200. }
  201. va_end(vargs);
  202. tuple_gc_track(result);
  203. return (PyObject *)result;
  204. }
  205. /* Methods */
  206. static void
  207. tupledealloc(PyTupleObject *op)
  208. {
  209. Py_ssize_t i;
  210. Py_ssize_t len = Py_SIZE(op);
  211. PyObject_GC_UnTrack(op);
  212. Py_TRASHCAN_BEGIN(op, tupledealloc)
  213. if (len > 0) {
  214. i = len;
  215. while (--i >= 0)
  216. Py_XDECREF(op->ob_item[i]);
  217. #if PyTuple_MAXSAVESIZE > 0
  218. if (len < PyTuple_MAXSAVESIZE &&
  219. numfree[len] < PyTuple_MAXFREELIST &&
  220. Py_IS_TYPE(op, &PyTuple_Type))
  221. {
  222. op->ob_item[0] = (PyObject *) free_list[len];
  223. numfree[len]++;
  224. free_list[len] = op;
  225. goto done; /* return */
  226. }
  227. #endif
  228. }
  229. Py_TYPE(op)->tp_free((PyObject *)op);
  230. done:
  231. Py_TRASHCAN_END
  232. }
  233. static PyObject *
  234. tuplerepr(PyTupleObject *v)
  235. {
  236. Py_ssize_t i, n;
  237. _PyUnicodeWriter writer;
  238. n = Py_SIZE(v);
  239. if (n == 0)
  240. return PyUnicode_FromString("()");
  241. /* While not mutable, it is still possible to end up with a cycle in a
  242. tuple through an object that stores itself within a tuple (and thus
  243. infinitely asks for the repr of itself). This should only be
  244. possible within a type. */
  245. i = Py_ReprEnter((PyObject *)v);
  246. if (i != 0) {
  247. return i > 0 ? PyUnicode_FromString("(...)") : NULL;
  248. }
  249. _PyUnicodeWriter_Init(&writer);
  250. writer.overallocate = 1;
  251. if (Py_SIZE(v) > 1) {
  252. /* "(" + "1" + ", 2" * (len - 1) + ")" */
  253. writer.min_length = 1 + 1 + (2 + 1) * (Py_SIZE(v) - 1) + 1;
  254. }
  255. else {
  256. /* "(1,)" */
  257. writer.min_length = 4;
  258. }
  259. if (_PyUnicodeWriter_WriteChar(&writer, '(') < 0)
  260. goto error;
  261. /* Do repr() on each element. */
  262. for (i = 0; i < n; ++i) {
  263. PyObject *s;
  264. if (i > 0) {
  265. if (_PyUnicodeWriter_WriteASCIIString(&writer, ", ", 2) < 0)
  266. goto error;
  267. }
  268. s = PyObject_Repr(v->ob_item[i]);
  269. if (s == NULL)
  270. goto error;
  271. if (_PyUnicodeWriter_WriteStr(&writer, s) < 0) {
  272. Py_DECREF(s);
  273. goto error;
  274. }
  275. Py_DECREF(s);
  276. }
  277. writer.overallocate = 0;
  278. if (n > 1) {
  279. if (_PyUnicodeWriter_WriteChar(&writer, ')') < 0)
  280. goto error;
  281. }
  282. else {
  283. if (_PyUnicodeWriter_WriteASCIIString(&writer, ",)", 2) < 0)
  284. goto error;
  285. }
  286. Py_ReprLeave((PyObject *)v);
  287. return _PyUnicodeWriter_Finish(&writer);
  288. error:
  289. _PyUnicodeWriter_Dealloc(&writer);
  290. Py_ReprLeave((PyObject *)v);
  291. return NULL;
  292. }
  293. /* Hash for tuples. This is a slightly simplified version of the xxHash
  294. non-cryptographic hash:
  295. - we do not use any parallellism, there is only 1 accumulator.
  296. - we drop the final mixing since this is just a permutation of the
  297. output space: it does not help against collisions.
  298. - at the end, we mangle the length with a single constant.
  299. For the xxHash specification, see
  300. https://github.com/Cyan4973/xxHash/blob/master/doc/xxhash_spec.md
  301. Below are the official constants from the xxHash specification. Optimizing
  302. compilers should emit a single "rotate" instruction for the
  303. _PyHASH_XXROTATE() expansion. If that doesn't happen for some important
  304. platform, the macro could be changed to expand to a platform-specific rotate
  305. spelling instead.
  306. */
  307. #if SIZEOF_PY_UHASH_T > 4
  308. #define _PyHASH_XXPRIME_1 ((Py_uhash_t)11400714785074694791ULL)
  309. #define _PyHASH_XXPRIME_2 ((Py_uhash_t)14029467366897019727ULL)
  310. #define _PyHASH_XXPRIME_5 ((Py_uhash_t)2870177450012600261ULL)
  311. #define _PyHASH_XXROTATE(x) ((x << 31) | (x >> 33)) /* Rotate left 31 bits */
  312. #else
  313. #define _PyHASH_XXPRIME_1 ((Py_uhash_t)2654435761UL)
  314. #define _PyHASH_XXPRIME_2 ((Py_uhash_t)2246822519UL)
  315. #define _PyHASH_XXPRIME_5 ((Py_uhash_t)374761393UL)
  316. #define _PyHASH_XXROTATE(x) ((x << 13) | (x >> 19)) /* Rotate left 13 bits */
  317. #endif
  318. /* Tests have shown that it's not worth to cache the hash value, see
  319. https://bugs.python.org/issue9685 */
  320. static Py_hash_t
  321. tuplehash(PyTupleObject *v)
  322. {
  323. Py_ssize_t i, len = Py_SIZE(v);
  324. PyObject **item = v->ob_item;
  325. Py_uhash_t acc = _PyHASH_XXPRIME_5;
  326. for (i = 0; i < len; i++) {
  327. Py_uhash_t lane = PyObject_Hash(item[i]);
  328. if (lane == (Py_uhash_t)-1) {
  329. return -1;
  330. }
  331. acc += lane * _PyHASH_XXPRIME_2;
  332. acc = _PyHASH_XXROTATE(acc);
  333. acc *= _PyHASH_XXPRIME_1;
  334. }
  335. /* Add input length, mangled to keep the historical value of hash(()). */
  336. acc += len ^ (_PyHASH_XXPRIME_5 ^ 3527539UL);
  337. if (acc == (Py_uhash_t)-1) {
  338. return 1546275796;
  339. }
  340. return acc;
  341. }
  342. static Py_ssize_t
  343. tuplelength(PyTupleObject *a)
  344. {
  345. return Py_SIZE(a);
  346. }
  347. static int
  348. tuplecontains(PyTupleObject *a, PyObject *el)
  349. {
  350. Py_ssize_t i;
  351. int cmp;
  352. for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i)
  353. cmp = PyObject_RichCompareBool(PyTuple_GET_ITEM(a, i), el, Py_EQ);
  354. return cmp;
  355. }
  356. static PyObject *
  357. tupleitem(PyTupleObject *a, Py_ssize_t i)
  358. {
  359. if (i < 0 || i >= Py_SIZE(a)) {
  360. PyErr_SetString(PyExc_IndexError, "tuple index out of range");
  361. return NULL;
  362. }
  363. Py_INCREF(a->ob_item[i]);
  364. return a->ob_item[i];
  365. }
  366. PyObject *
  367. _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  368. {
  369. if (n == 0) {
  370. return PyTuple_New(0);
  371. }
  372. PyTupleObject *tuple = tuple_alloc(n);
  373. if (tuple == NULL) {
  374. return NULL;
  375. }
  376. PyObject **dst = tuple->ob_item;
  377. for (Py_ssize_t i = 0; i < n; i++) {
  378. PyObject *item = src[i];
  379. Py_INCREF(item);
  380. dst[i] = item;
  381. }
  382. tuple_gc_track(tuple);
  383. return (PyObject *)tuple;
  384. }
  385. static PyObject *
  386. tupleslice(PyTupleObject *a, Py_ssize_t ilow,
  387. Py_ssize_t ihigh)
  388. {
  389. if (ilow < 0)
  390. ilow = 0;
  391. if (ihigh > Py_SIZE(a))
  392. ihigh = Py_SIZE(a);
  393. if (ihigh < ilow)
  394. ihigh = ilow;
  395. if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) {
  396. Py_INCREF(a);
  397. return (PyObject *)a;
  398. }
  399. return _PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow);
  400. }
  401. PyObject *
  402. PyTuple_GetSlice(PyObject *op, Py_ssize_t i, Py_ssize_t j)
  403. {
  404. if (op == NULL || !PyTuple_Check(op)) {
  405. PyErr_BadInternalCall();
  406. return NULL;
  407. }
  408. return tupleslice((PyTupleObject *)op, i, j);
  409. }
  410. static PyObject *
  411. tupleconcat(PyTupleObject *a, PyObject *bb)
  412. {
  413. Py_ssize_t size;
  414. Py_ssize_t i;
  415. PyObject **src, **dest;
  416. PyTupleObject *np;
  417. if (Py_SIZE(a) == 0 && PyTuple_CheckExact(bb)) {
  418. Py_INCREF(bb);
  419. return bb;
  420. }
  421. if (!PyTuple_Check(bb)) {
  422. PyErr_Format(PyExc_TypeError,
  423. "can only concatenate tuple (not \"%.200s\") to tuple",
  424. Py_TYPE(bb)->tp_name);
  425. return NULL;
  426. }
  427. #define b ((PyTupleObject *)bb)
  428. if (Py_SIZE(b) == 0 && PyTuple_CheckExact(a)) {
  429. Py_INCREF(a);
  430. return (PyObject *)a;
  431. }
  432. if (Py_SIZE(a) > PY_SSIZE_T_MAX - Py_SIZE(b))
  433. return PyErr_NoMemory();
  434. size = Py_SIZE(a) + Py_SIZE(b);
  435. if (size == 0) {
  436. return PyTuple_New(0);
  437. }
  438. np = tuple_alloc(size);
  439. if (np == NULL) {
  440. return NULL;
  441. }
  442. src = a->ob_item;
  443. dest = np->ob_item;
  444. for (i = 0; i < Py_SIZE(a); i++) {
  445. PyObject *v = src[i];
  446. Py_INCREF(v);
  447. dest[i] = v;
  448. }
  449. src = b->ob_item;
  450. dest = np->ob_item + Py_SIZE(a);
  451. for (i = 0; i < Py_SIZE(b); i++) {
  452. PyObject *v = src[i];
  453. Py_INCREF(v);
  454. dest[i] = v;
  455. }
  456. tuple_gc_track(np);
  457. return (PyObject *)np;
  458. #undef b
  459. }
  460. static PyObject *
  461. tuplerepeat(PyTupleObject *a, Py_ssize_t n)
  462. {
  463. Py_ssize_t i, j;
  464. Py_ssize_t size;
  465. PyTupleObject *np;
  466. PyObject **p, **items;
  467. if (Py_SIZE(a) == 0 || n == 1) {
  468. if (PyTuple_CheckExact(a)) {
  469. /* Since tuples are immutable, we can return a shared
  470. copy in this case */
  471. Py_INCREF(a);
  472. return (PyObject *)a;
  473. }
  474. }
  475. if (Py_SIZE(a) == 0 || n <= 0) {
  476. return PyTuple_New(0);
  477. }
  478. if (n > PY_SSIZE_T_MAX / Py_SIZE(a))
  479. return PyErr_NoMemory();
  480. size = Py_SIZE(a) * n;
  481. np = tuple_alloc(size);
  482. if (np == NULL)
  483. return NULL;
  484. p = np->ob_item;
  485. items = a->ob_item;
  486. for (i = 0; i < n; i++) {
  487. for (j = 0; j < Py_SIZE(a); j++) {
  488. *p = items[j];
  489. Py_INCREF(*p);
  490. p++;
  491. }
  492. }
  493. tuple_gc_track(np);
  494. return (PyObject *) np;
  495. }
  496. /*[clinic input]
  497. tuple.index
  498. value: object
  499. start: slice_index(accept={int}) = 0
  500. stop: slice_index(accept={int}, c_default="PY_SSIZE_T_MAX") = sys.maxsize
  501. /
  502. Return first index of value.
  503. Raises ValueError if the value is not present.
  504. [clinic start generated code]*/
  505. static PyObject *
  506. tuple_index_impl(PyTupleObject *self, PyObject *value, Py_ssize_t start,
  507. Py_ssize_t stop)
  508. /*[clinic end generated code: output=07b6f9f3cb5c33eb input=fb39e9874a21fe3f]*/
  509. {
  510. Py_ssize_t i;
  511. if (start < 0) {
  512. start += Py_SIZE(self);
  513. if (start < 0)
  514. start = 0;
  515. }
  516. if (stop < 0) {
  517. stop += Py_SIZE(self);
  518. }
  519. else if (stop > Py_SIZE(self)) {
  520. stop = Py_SIZE(self);
  521. }
  522. for (i = start; i < stop; i++) {
  523. int cmp = PyObject_RichCompareBool(self->ob_item[i], value, Py_EQ);
  524. if (cmp > 0)
  525. return PyLong_FromSsize_t(i);
  526. else if (cmp < 0)
  527. return NULL;
  528. }
  529. PyErr_SetString(PyExc_ValueError, "tuple.index(x): x not in tuple");
  530. return NULL;
  531. }
  532. /*[clinic input]
  533. tuple.count
  534. value: object
  535. /
  536. Return number of occurrences of value.
  537. [clinic start generated code]*/
  538. static PyObject *
  539. tuple_count(PyTupleObject *self, PyObject *value)
  540. /*[clinic end generated code: output=aa927affc5a97605 input=531721aff65bd772]*/
  541. {
  542. Py_ssize_t count = 0;
  543. Py_ssize_t i;
  544. for (i = 0; i < Py_SIZE(self); i++) {
  545. int cmp = PyObject_RichCompareBool(self->ob_item[i], value, Py_EQ);
  546. if (cmp > 0)
  547. count++;
  548. else if (cmp < 0)
  549. return NULL;
  550. }
  551. return PyLong_FromSsize_t(count);
  552. }
  553. static int
  554. tupletraverse(PyTupleObject *o, visitproc visit, void *arg)
  555. {
  556. Py_ssize_t i;
  557. for (i = Py_SIZE(o); --i >= 0; )
  558. Py_VISIT(o->ob_item[i]);
  559. return 0;
  560. }
  561. static PyObject *
  562. tuplerichcompare(PyObject *v, PyObject *w, int op)
  563. {
  564. PyTupleObject *vt, *wt;
  565. Py_ssize_t i;
  566. Py_ssize_t vlen, wlen;
  567. if (!PyTuple_Check(v) || !PyTuple_Check(w))
  568. Py_RETURN_NOTIMPLEMENTED;
  569. vt = (PyTupleObject *)v;
  570. wt = (PyTupleObject *)w;
  571. vlen = Py_SIZE(vt);
  572. wlen = Py_SIZE(wt);
  573. /* Note: the corresponding code for lists has an "early out" test
  574. * here when op is EQ or NE and the lengths differ. That pays there,
  575. * but Tim was unable to find any real code where EQ/NE tuple
  576. * compares don't have the same length, so testing for it here would
  577. * have cost without benefit.
  578. */
  579. /* Search for the first index where items are different.
  580. * Note that because tuples are immutable, it's safe to reuse
  581. * vlen and wlen across the comparison calls.
  582. */
  583. for (i = 0; i < vlen && i < wlen; i++) {
  584. int k = PyObject_RichCompareBool(vt->ob_item[i],
  585. wt->ob_item[i], Py_EQ);
  586. if (k < 0)
  587. return NULL;
  588. if (!k)
  589. break;
  590. }
  591. if (i >= vlen || i >= wlen) {
  592. /* No more items to compare -- compare sizes */
  593. Py_RETURN_RICHCOMPARE(vlen, wlen, op);
  594. }
  595. /* We have an item that differs -- shortcuts for EQ/NE */
  596. if (op == Py_EQ) {
  597. Py_RETURN_FALSE;
  598. }
  599. if (op == Py_NE) {
  600. Py_RETURN_TRUE;
  601. }
  602. /* Compare the final item again using the proper operator */
  603. return PyObject_RichCompare(vt->ob_item[i], wt->ob_item[i], op);
  604. }
  605. static PyObject *
  606. tuple_subtype_new(PyTypeObject *type, PyObject *iterable);
  607. /*[clinic input]
  608. @classmethod
  609. tuple.__new__ as tuple_new
  610. iterable: object(c_default="NULL") = ()
  611. /
  612. Built-in immutable sequence.
  613. If no argument is given, the constructor returns an empty tuple.
  614. If iterable is specified the tuple is initialized from iterable's items.
  615. If the argument is a tuple, the return value is the same object.
  616. [clinic start generated code]*/
  617. static PyObject *
  618. tuple_new_impl(PyTypeObject *type, PyObject *iterable)
  619. /*[clinic end generated code: output=4546d9f0d469bce7 input=86963bcde633b5a2]*/
  620. {
  621. if (type != &PyTuple_Type)
  622. return tuple_subtype_new(type, iterable);
  623. if (iterable == NULL)
  624. return PyTuple_New(0);
  625. else
  626. return PySequence_Tuple(iterable);
  627. }
  628. static PyObject *
  629. tuple_vectorcall(PyObject *type, PyObject * const*args,
  630. size_t nargsf, PyObject *kwnames)
  631. {
  632. if (!_PyArg_NoKwnames("tuple", kwnames)) {
  633. return NULL;
  634. }
  635. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  636. if (!_PyArg_CheckPositional("tuple", nargs, 0, 1)) {
  637. return NULL;
  638. }
  639. if (nargs) {
  640. return tuple_new_impl((PyTypeObject *)type, args[0]);
  641. }
  642. return PyTuple_New(0);
  643. }
  644. static PyObject *
  645. tuple_subtype_new(PyTypeObject *type, PyObject *iterable)
  646. {
  647. PyObject *tmp, *newobj, *item;
  648. Py_ssize_t i, n;
  649. assert(PyType_IsSubtype(type, &PyTuple_Type));
  650. tmp = tuple_new_impl(&PyTuple_Type, iterable);
  651. if (tmp == NULL)
  652. return NULL;
  653. assert(PyTuple_Check(tmp));
  654. newobj = type->tp_alloc(type, n = PyTuple_GET_SIZE(tmp));
  655. if (newobj == NULL) {
  656. Py_DECREF(tmp);
  657. return NULL;
  658. }
  659. for (i = 0; i < n; i++) {
  660. item = PyTuple_GET_ITEM(tmp, i);
  661. Py_INCREF(item);
  662. PyTuple_SET_ITEM(newobj, i, item);
  663. }
  664. Py_DECREF(tmp);
  665. return newobj;
  666. }
  667. static PySequenceMethods tuple_as_sequence = {
  668. (lenfunc)tuplelength, /* sq_length */
  669. (binaryfunc)tupleconcat, /* sq_concat */
  670. (ssizeargfunc)tuplerepeat, /* sq_repeat */
  671. (ssizeargfunc)tupleitem, /* sq_item */
  672. 0, /* sq_slice */
  673. 0, /* sq_ass_item */
  674. 0, /* sq_ass_slice */
  675. (objobjproc)tuplecontains, /* sq_contains */
  676. };
  677. static PyObject*
  678. tuplesubscript(PyTupleObject* self, PyObject* item)
  679. {
  680. if (_PyIndex_Check(item)) {
  681. Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
  682. if (i == -1 && PyErr_Occurred())
  683. return NULL;
  684. if (i < 0)
  685. i += PyTuple_GET_SIZE(self);
  686. return tupleitem(self, i);
  687. }
  688. else if (PySlice_Check(item)) {
  689. Py_ssize_t start, stop, step, slicelength, i;
  690. size_t cur;
  691. PyObject* it;
  692. PyObject **src, **dest;
  693. if (PySlice_Unpack(item, &start, &stop, &step) < 0) {
  694. return NULL;
  695. }
  696. slicelength = PySlice_AdjustIndices(PyTuple_GET_SIZE(self), &start,
  697. &stop, step);
  698. if (slicelength <= 0) {
  699. return PyTuple_New(0);
  700. }
  701. else if (start == 0 && step == 1 &&
  702. slicelength == PyTuple_GET_SIZE(self) &&
  703. PyTuple_CheckExact(self)) {
  704. Py_INCREF(self);
  705. return (PyObject *)self;
  706. }
  707. else {
  708. PyTupleObject* result = tuple_alloc(slicelength);
  709. if (!result) return NULL;
  710. src = self->ob_item;
  711. dest = result->ob_item;
  712. for (cur = start, i = 0; i < slicelength;
  713. cur += step, i++) {
  714. it = src[cur];
  715. Py_INCREF(it);
  716. dest[i] = it;
  717. }
  718. tuple_gc_track(result);
  719. return (PyObject *)result;
  720. }
  721. }
  722. else {
  723. PyErr_Format(PyExc_TypeError,
  724. "tuple indices must be integers or slices, not %.200s",
  725. Py_TYPE(item)->tp_name);
  726. return NULL;
  727. }
  728. }
  729. /*[clinic input]
  730. tuple.__getnewargs__
  731. [clinic start generated code]*/
  732. static PyObject *
  733. tuple___getnewargs___impl(PyTupleObject *self)
  734. /*[clinic end generated code: output=25e06e3ee56027e2 input=1aeb4b286a21639a]*/
  735. {
  736. return Py_BuildValue("(N)", tupleslice(self, 0, Py_SIZE(self)));
  737. }
  738. static PyMethodDef tuple_methods[] = {
  739. TUPLE___GETNEWARGS___METHODDEF
  740. TUPLE_INDEX_METHODDEF
  741. TUPLE_COUNT_METHODDEF
  742. {"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
  743. {NULL, NULL} /* sentinel */
  744. };
  745. static PyMappingMethods tuple_as_mapping = {
  746. (lenfunc)tuplelength,
  747. (binaryfunc)tuplesubscript,
  748. 0
  749. };
  750. static PyObject *tuple_iter(PyObject *seq);
  751. PyTypeObject PyTuple_Type = {
  752. PyVarObject_HEAD_INIT(&PyType_Type, 0)
  753. "tuple",
  754. sizeof(PyTupleObject) - sizeof(PyObject *),
  755. sizeof(PyObject *),
  756. (destructor)tupledealloc, /* tp_dealloc */
  757. 0, /* tp_vectorcall_offset */
  758. 0, /* tp_getattr */
  759. 0, /* tp_setattr */
  760. 0, /* tp_as_async */
  761. (reprfunc)tuplerepr, /* tp_repr */
  762. 0, /* tp_as_number */
  763. &tuple_as_sequence, /* tp_as_sequence */
  764. &tuple_as_mapping, /* tp_as_mapping */
  765. (hashfunc)tuplehash, /* tp_hash */
  766. 0, /* tp_call */
  767. 0, /* tp_str */
  768. PyObject_GenericGetAttr, /* tp_getattro */
  769. 0, /* tp_setattro */
  770. 0, /* tp_as_buffer */
  771. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
  772. Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TUPLE_SUBCLASS, /* tp_flags */
  773. tuple_new__doc__, /* tp_doc */
  774. (traverseproc)tupletraverse, /* tp_traverse */
  775. 0, /* tp_clear */
  776. tuplerichcompare, /* tp_richcompare */
  777. 0, /* tp_weaklistoffset */
  778. tuple_iter, /* tp_iter */
  779. 0, /* tp_iternext */
  780. tuple_methods, /* tp_methods */
  781. 0, /* tp_members */
  782. 0, /* tp_getset */
  783. 0, /* tp_base */
  784. 0, /* tp_dict */
  785. 0, /* tp_descr_get */
  786. 0, /* tp_descr_set */
  787. 0, /* tp_dictoffset */
  788. 0, /* tp_init */
  789. 0, /* tp_alloc */
  790. tuple_new, /* tp_new */
  791. PyObject_GC_Del, /* tp_free */
  792. .tp_vectorcall = tuple_vectorcall,
  793. };
  794. /* The following function breaks the notion that tuples are immutable:
  795. it changes the size of a tuple. We get away with this only if there
  796. is only one module referencing the object. You can also think of it
  797. as creating a new tuple object and destroying the old one, only more
  798. efficiently. In any case, don't use this if the tuple may already be
  799. known to some other part of the code. */
  800. int
  801. _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
  802. {
  803. PyTupleObject *v;
  804. PyTupleObject *sv;
  805. Py_ssize_t i;
  806. Py_ssize_t oldsize;
  807. v = (PyTupleObject *) *pv;
  808. if (v == NULL || !Py_IS_TYPE(v, &PyTuple_Type) ||
  809. (Py_SIZE(v) != 0 && Py_REFCNT(v) != 1)) {
  810. *pv = 0;
  811. Py_XDECREF(v);
  812. PyErr_BadInternalCall();
  813. return -1;
  814. }
  815. oldsize = Py_SIZE(v);
  816. if (oldsize == newsize)
  817. return 0;
  818. if (oldsize == 0) {
  819. /* Empty tuples are often shared, so we should never
  820. resize them in-place even if we do own the only
  821. (current) reference */
  822. Py_DECREF(v);
  823. *pv = PyTuple_New(newsize);
  824. return *pv == NULL ? -1 : 0;
  825. }
  826. /* XXX UNREF/NEWREF interface should be more symmetrical */
  827. #ifdef Py_REF_DEBUG
  828. _Py_RefTotal--;
  829. #endif
  830. if (_PyObject_GC_IS_TRACKED(v)) {
  831. _PyObject_GC_UNTRACK(v);
  832. }
  833. #ifdef Py_TRACE_REFS
  834. _Py_ForgetReference((PyObject *) v);
  835. #endif
  836. /* DECREF items deleted by shrinkage */
  837. for (i = newsize; i < oldsize; i++) {
  838. Py_CLEAR(v->ob_item[i]);
  839. }
  840. sv = PyObject_GC_Resize(PyTupleObject, v, newsize);
  841. if (sv == NULL) {
  842. *pv = NULL;
  843. PyObject_GC_Del(v);
  844. return -1;
  845. }
  846. _Py_NewReference((PyObject *) sv);
  847. /* Zero out items added by growing */
  848. if (newsize > oldsize)
  849. memset(&sv->ob_item[oldsize], 0,
  850. sizeof(*sv->ob_item) * (newsize - oldsize));
  851. *pv = (PyObject *) sv;
  852. _PyObject_GC_TRACK(sv);
  853. return 0;
  854. }
  855. int
  856. PyTuple_ClearFreeList(void)
  857. {
  858. int freelist_size = 0;
  859. #if PyTuple_MAXSAVESIZE > 0
  860. int i;
  861. for (i = 1; i < PyTuple_MAXSAVESIZE; i++) {
  862. PyTupleObject *p, *q;
  863. p = free_list[i];
  864. freelist_size += numfree[i];
  865. free_list[i] = NULL;
  866. numfree[i] = 0;
  867. while (p) {
  868. q = p;
  869. p = (PyTupleObject *)(p->ob_item[0]);
  870. PyObject_GC_Del(q);
  871. }
  872. }
  873. #endif
  874. return freelist_size;
  875. }
  876. void
  877. _PyTuple_Fini(void)
  878. {
  879. #if PyTuple_MAXSAVESIZE > 0
  880. /* empty tuples are used all over the place and applications may
  881. * rely on the fact that an empty tuple is a singleton. */
  882. Py_CLEAR(free_list[0]);
  883. (void)PyTuple_ClearFreeList();
  884. #endif
  885. }
  886. /*********************** Tuple Iterator **************************/
  887. typedef struct {
  888. PyObject_HEAD
  889. Py_ssize_t it_index;
  890. PyTupleObject *it_seq; /* Set to NULL when iterator is exhausted */
  891. } tupleiterobject;
  892. static void
  893. tupleiter_dealloc(tupleiterobject *it)
  894. {
  895. _PyObject_GC_UNTRACK(it);
  896. Py_XDECREF(it->it_seq);
  897. PyObject_GC_Del(it);
  898. }
  899. static int
  900. tupleiter_traverse(tupleiterobject *it, visitproc visit, void *arg)
  901. {
  902. Py_VISIT(it->it_seq);
  903. return 0;
  904. }
  905. static PyObject *
  906. tupleiter_next(tupleiterobject *it)
  907. {
  908. PyTupleObject *seq;
  909. PyObject *item;
  910. assert(it != NULL);
  911. seq = it->it_seq;
  912. if (seq == NULL)
  913. return NULL;
  914. assert(PyTuple_Check(seq));
  915. if (it->it_index < PyTuple_GET_SIZE(seq)) {
  916. item = PyTuple_GET_ITEM(seq, it->it_index);
  917. ++it->it_index;
  918. Py_INCREF(item);
  919. return item;
  920. }
  921. it->it_seq = NULL;
  922. Py_DECREF(seq);
  923. return NULL;
  924. }
  925. static PyObject *
  926. tupleiter_len(tupleiterobject *it, PyObject *Py_UNUSED(ignored))
  927. {
  928. Py_ssize_t len = 0;
  929. if (it->it_seq)
  930. len = PyTuple_GET_SIZE(it->it_seq) - it->it_index;
  931. return PyLong_FromSsize_t(len);
  932. }
  933. PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");
  934. static PyObject *
  935. tupleiter_reduce(tupleiterobject *it, PyObject *Py_UNUSED(ignored))
  936. {
  937. _Py_IDENTIFIER(iter);
  938. if (it->it_seq)
  939. return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
  940. it->it_seq, it->it_index);
  941. else
  942. return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter));
  943. }
  944. static PyObject *
  945. tupleiter_setstate(tupleiterobject *it, PyObject *state)
  946. {
  947. Py_ssize_t index = PyLong_AsSsize_t(state);
  948. if (index == -1 && PyErr_Occurred())
  949. return NULL;
  950. if (it->it_seq != NULL) {
  951. if (index < 0)
  952. index = 0;
  953. else if (index > PyTuple_GET_SIZE(it->it_seq))
  954. index = PyTuple_GET_SIZE(it->it_seq); /* exhausted iterator */
  955. it->it_index = index;
  956. }
  957. Py_RETURN_NONE;
  958. }
  959. PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
  960. PyDoc_STRVAR(setstate_doc, "Set state information for unpickling.");
  961. static PyMethodDef tupleiter_methods[] = {
  962. {"__length_hint__", (PyCFunction)tupleiter_len, METH_NOARGS, length_hint_doc},
  963. {"__reduce__", (PyCFunction)tupleiter_reduce, METH_NOARGS, reduce_doc},
  964. {"__setstate__", (PyCFunction)tupleiter_setstate, METH_O, setstate_doc},
  965. {NULL, NULL} /* sentinel */
  966. };
  967. PyTypeObject PyTupleIter_Type = {
  968. PyVarObject_HEAD_INIT(&PyType_Type, 0)
  969. "tuple_iterator", /* tp_name */
  970. sizeof(tupleiterobject), /* tp_basicsize */
  971. 0, /* tp_itemsize */
  972. /* methods */
  973. (destructor)tupleiter_dealloc, /* tp_dealloc */
  974. 0, /* tp_vectorcall_offset */
  975. 0, /* tp_getattr */
  976. 0, /* tp_setattr */
  977. 0, /* tp_as_async */
  978. 0, /* tp_repr */
  979. 0, /* tp_as_number */
  980. 0, /* tp_as_sequence */
  981. 0, /* tp_as_mapping */
  982. 0, /* tp_hash */
  983. 0, /* tp_call */
  984. 0, /* tp_str */
  985. PyObject_GenericGetAttr, /* tp_getattro */
  986. 0, /* tp_setattro */
  987. 0, /* tp_as_buffer */
  988. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
  989. 0, /* tp_doc */
  990. (traverseproc)tupleiter_traverse, /* tp_traverse */
  991. 0, /* tp_clear */
  992. 0, /* tp_richcompare */
  993. 0, /* tp_weaklistoffset */
  994. PyObject_SelfIter, /* tp_iter */
  995. (iternextfunc)tupleiter_next, /* tp_iternext */
  996. tupleiter_methods, /* tp_methods */
  997. 0,
  998. };
  999. static PyObject *
  1000. tuple_iter(PyObject *seq)
  1001. {
  1002. tupleiterobject *it;
  1003. if (!PyTuple_Check(seq)) {
  1004. PyErr_BadInternalCall();
  1005. return NULL;
  1006. }
  1007. it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type);
  1008. if (it == NULL)
  1009. return NULL;
  1010. it->it_index = 0;
  1011. Py_INCREF(seq);
  1012. it->it_seq = (PyTupleObject *)seq;
  1013. _PyObject_GC_TRACK(it);
  1014. return (PyObject *)it;
  1015. }