summaryrefslogtreecommitdiff
path: root/Objects/tupleobject.c
AgeCommit message (Collapse)AuthorLines
2010-05-09Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou-696/+696
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
2010-03-01Merged revisions 78515-78516,78522 via svnmerge fromEzio Melotti-4/+4
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78515 | georg.brandl | 2010-02-28 20:19:17 +0200 (Sun, 28 Feb 2010) | 1 line #8030: make builtin type docstrings more consistent: use "iterable" instead of "seq(uence)", use "new" to show that set() always returns a new object. ........ r78516 | georg.brandl | 2010-02-28 20:26:37 +0200 (Sun, 28 Feb 2010) | 1 line The set types can also be called without arguments. ........ r78522 | ezio.melotti | 2010-03-01 01:59:00 +0200 (Mon, 01 Mar 2010) | 1 line #8030: more docstring fix for builtin types. ........
2008-10-04Merged revisions ↵Benjamin Peterson-1/+3
66766-66767,66771-66772,66774,66776,66783-66787,66790,66793,66797 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ................ r66766 | benjamin.peterson | 2008-10-03 06:52:06 -0500 (Fri, 03 Oct 2008) | 1 line update the mac installer script ................ r66767 | andrew.kuchling | 2008-10-03 07:26:42 -0500 (Fri, 03 Oct 2008) | 1 line Docstring typo. ................ r66771 | hirokazu.yamamoto | 2008-10-03 11:18:42 -0500 (Fri, 03 Oct 2008) | 2 lines Fixed following error when DocXMLRPCServer failed. UnboundLocalError: local variable 'serv' referenced before assignment ................ r66772 | andrew.kuchling | 2008-10-03 11:29:19 -0500 (Fri, 03 Oct 2008) | 1 line Mention exception in docstring ................ r66774 | andrew.kuchling | 2008-10-03 11:42:52 -0500 (Fri, 03 Oct 2008) | 1 line Typo fix ................ r66776 | hirokazu.yamamoto | 2008-10-03 12:34:49 -0500 (Fri, 03 Oct 2008) | 2 lines Issue #1706863: Fixed "'NoneType' object has no attribute 'rfind'" error when sqlite libfile not found. ................ r66783 | andrew.kuchling | 2008-10-03 20:02:29 -0500 (Fri, 03 Oct 2008) | 1 line Use correct capitalization of NaN ................ r66784 | andrew.kuchling | 2008-10-03 20:03:42 -0500 (Fri, 03 Oct 2008) | 1 line Docstring change: Specify exception raised ................ r66785 | andrew.kuchling | 2008-10-03 20:04:24 -0500 (Fri, 03 Oct 2008) | 1 line Docstring changes: Specify exceptions raised ................ r66786 | andrew.kuchling | 2008-10-03 20:05:56 -0500 (Fri, 03 Oct 2008) | 3 lines Docstring change for *partition: use same tense as other docstrings. Hyphenate left- and right-justified. Fix 'registerd' typo ................ r66787 | andrew.kuchling | 2008-10-03 22:08:56 -0500 (Fri, 03 Oct 2008) | 1 line two corrections ................ r66790 | andrew.kuchling | 2008-10-04 11:52:01 -0500 (Sat, 04 Oct 2008) | 1 line Set svn:keywords ................ r66793 | georg.brandl | 2008-10-04 13:26:01 -0500 (Sat, 04 Oct 2008) | 2 lines #4041: don't refer to removed and outdated modules. ................ r66797 | benjamin.peterson | 2008-10-04 15:55:50 -0500 (Sat, 04 Oct 2008) | 19 lines Merged revisions 66707,66775,66782 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r66707 | benjamin.peterson | 2008-09-30 18:27:10 -0500 (Tue, 30 Sep 2008) | 1 line fix #4001: fix_imports didn't check for __init__.py before converting to relative imports ........ r66775 | collin.winter | 2008-10-03 12:08:26 -0500 (Fri, 03 Oct 2008) | 4 lines Add an alternative iterative pattern matching system that, while slower, correctly parses files that cause the faster recursive pattern matcher to fail with a recursion error. lib2to3 falls back to the iterative matcher if the recursive one fails. Fixes http://bugs.python.org/issue2532. Thanks to Nick Edds. ........ r66782 | benjamin.peterson | 2008-10-03 17:51:36 -0500 (Fri, 03 Oct 2008) | 1 line add Victor Stinner's fixer for os.getcwdu -> os.getcwd #4023 ........ ................
2008-07-31Security patches from Apple: prevent int overflow when allocating memoryNeal Norwitz-2/+3
2008-06-13Fixed: sys.getsizeof does not take the actual length of the tuples into account.Robert Schuppenies-0/+12
2008-06-09This reverts r63675 based on the discussion in this thread:Gregory P. Smith-8/+8
http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
2008-05-26Renamed PyString to PyBytesChristian Heimes-8/+8
2008-02-14Implemented Martin's suggestion to clear the free lists during the garbage ↵Christian Heimes-6/+19
collection of the highest generation.
2008-02-07Return ints instead of longs for tuple.count() and tuple.index().Raymond Hettinger-2/+2
2008-02-07Issue 2025: Add tuple.count() and tuple.index() to follow the ABC in ↵Raymond Hettinger-0/+54
collections.Sequence.
2008-02-06Unified naming convention for free lists and their limits. All free listsChristian Heimes-29/+29
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.
2007-12-19#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes-36/+36
Py_REFCNT. Macros for b/w compatibility are available.
2007-09-30Fix error introduced by r58288; if a tuple is length 0 return its repr andBrett Cannon-4/+4
don't worry about any self-referring tuples.
2007-09-30tuple.__repr__ did not consider a reference loop as it is not possible fromBrett Cannon-0/+13
Python code; but it is possible from C. object.__str__ had the issue of not expecting a type to doing something within it's tp_str implementation that could trigger an infinite recursion, but it could in C code.. Both found thanks to BaseException and how it handles its repr. Closes issue #1686386. Thanks to Thomas Herve for taking an initial stab at coming up with a solution.
2007-09-17Add a bunch of GIL release/acquire points in tp_print implementations and forBrett Cannon-2/+10
PyObject_Print(). Closes issue #1164.
2007-08-28Improve extended slicing support in builtin types and classes. Specifically:Thomas Wouters-0/+6
- Specialcase extended slices that amount to a shallow copy the same way as is done for simple slices, in the tuple, string and unicode case. - Specialcase step-1 extended slices to optimize the common case for all involved types. - For lists, allow extended slice assignment of differing lengths as long as the step is 1. (Previously, 'l[:2:1] = []' failed even though 'l[:2] = []' and 'l[:2:None] = []' do not.) - Implement extended slicing for buffer, array, structseq, mmap and UserString.UserString. - Implement slice-object support (but not non-step-1 slice assignment) for UserString.MutableString. - Add tests for all new functionality.
2007-07-21PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis-40/+38
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
2007-02-25Variation of patch # 1624059 to speed up checking if an object is a subclassNeal Norwitz-1/+1
of some of the common builtin types. Use a bit in tp_flags for each common builtin type. Check the bit to determine if any instance is a subclass of these common types. The check avoids a function call and O(n) search of the base classes. The check is done in the various Py*_Check macros rather than calling PyType_IsSubtype(). All the bits are set in tp_flags when the type is declared in the Objects/*object.c files because PyType_Ready() is not called for all the types. Should PyType_Ready() be called for all types? If so and the change is made, the changes to the Objects/*object.c files can be reverted (remove setting the tp_flags). Objects/typeobject.c would also have to be modified to add conditions for Py*_CheckExact() in addition to each the PyType_IsSubtype check.
2006-11-19Patch [ 1586791 ] better error msgs for some TypeErrorsGeorg Brandl-2/+3
2006-08-12Patch #1538606, Patch to fix __index__() clipping.Neal Norwitz-5/+2
I modified this patch some by fixing style, some error checking, and adding XXX comments. This patch requires review and some changes are to be expected. I'm checking in now to get the greatest possible review and establish a baseline for moving forward. I don't want this to hold up release if possible.
2006-04-15Use Py_VISIT in all tp_traverse methods, instead of traversing manually orThomas Wouters-12/+4
using a custom, nearly-identical macro. This probably changes how some of these functions are compiled, which may result in fractionally slower (or faster) execution. Considering the nature of traversal, visiting much of the address space in unpredictable patterns, I'd argue the code readability and maintainability is well worth it ;P
2006-04-11Remove "static forward" declaration. Move constructorsMartin v. Löwis-21/+19
after the type objects.
2006-04-11More low-hanging fruit. Still need to re-arrange some code (or find a betterAnthony Baxter-5/+5
solution) in the same way as listobject.c got changed. Hoping for a better solution.
2006-03-17Fix some missing checks after PyTuple_New, PyList_New, PyDict_NewGeorg Brandl-0/+1
2006-03-07Checking in the code for PEP 357.Guido van Rossum-2/+5
This was mostly written by Travis Oliphant. I've inspected it all; Neal Norwitz and MvL have also looked at it (in an earlier incarnation).
2006-02-27Revert backwards-incompatible const changes.Martin v. Löwis-1/+1
2006-02-16Use Py_ssize_t for counts and sizes.Martin v. Löwis-3/+4
Convert Py_ssize_t using PyInt_FromSsize_t
2006-02-15Merge ssize_t branch.Martin v. Löwis-48/+44
2006-02-11Renamed _length_cue() to __length_hint__(). See:Armin Rigo-2/+2
http://mail.python.org/pipermail/python-dev/2006-February/060524.html
2005-12-10Add const to several API functions that take char *.Jeremy Hylton-1/+1
In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
2005-09-24Convert iterator __len__() methods to a private API.Raymond Hettinger-7/+12
2004-06-10Add a final permutation step to the tuple hash function.Raymond Hettinger-0/+1
Prevents a collision pattern that occurs with nested tuples. (Yitz Gale provided code that repeatably demonstrated the weakness.)
2004-06-04Replaced arbitrary addend in tuple_hash with one that is known to generateRaymond Hettinger-1/+9
many more prime multipliers and that performs well on collision tests.
2004-06-01SF bug #942952: Weakness in tuple hashRaymond Hettinger-2/+3
(Basic approach and test concept by Tim Peters.) * Improved the hash to reduce collisions. * Added the torture test to the test suite.
2004-03-21Restored revision 2.87.Armin Rigo-12/+5
2004-03-21PyTuple_New(): vrbl i no longer referenced, so removed it (which killsTim Peters-1/+1
off a new compiler wng under MSVC6).
2004-03-21This is the fastest I could get on Intel GCC. I kept the memset() in to clearArmin Rigo-4/+11
the newly created tuples, but tuples added in the freelist are now cleared in tupledealloc already (which is very cheap, because we are already Py_XDECREF'ing all elements anyway). Python should have a standard Py_ZAP macro like ZAP in pystate.c.
2004-03-20memset() hunt continuing. This is a net win.Armin Rigo-1/+3
2004-03-18Make iterators length transparent where possible.Raymond Hettinger-1/+14
2004-03-15Eliminate an unnecessary test on a common code path.Raymond Hettinger-3/+1
2004-03-09Optimize inner loops for subscript, repeat, and concat.Raymond Hettinger-9/+20
2004-03-08Optimize tuple_slice() and make further improvements to list_slice()Raymond Hettinger-4/+9
and list.extend(). Factoring the inner loops to remove the constant structure references and fixed offsets gives speedups ranging from 20% to 30%.
2003-10-12Extended tuple's C API to include a new function, PyTuple_Pack() that isRaymond Hettinger-0/+22
useful for rapidly building argument tuples without having to invoke the more sophisticated machinery of Py_BuildValue().
2003-05-07SF bug #730296: Unexpected Changes in list IteratorRaymond Hettinger-2/+0
Reverted a Py2.3b1 change to iterator in subclasses of list and tuple. They had been changed to use __getitem__ whenever it had been overriden in the subclass. This caused some usabilty and performance problems. Also, it was inconsistent with the rest of python where many container methods access the underlying object directly without first checking for an overridden getter. Users needing a change in iterator behavior should override it directly.
2003-04-24Squashed new compiler wngs about trying to compare pointers toTim Peters-1/+1
functions with different signatures.
2003-04-24SF bug 665835: filter() treatment of str and tuple inconsistentRaymond Hettinger-0/+2
As a side issue on this bug, it was noted that list and tuple iterators used macros to directly access containers and would not recognize __getitem__ overrides. If the method is overridden, the patch returns a generic sequence iterator which calls the __getitem__ method; otherwise, it returns a high custom iterator with direct access to container elements.
2003-03-17Renamed PyObject_GenericGetIter to PyObject_SelfIterRaymond Hettinger-1/+1
to more accurately describe what the function does. Suggested by Thomas Wouters.
2003-03-17Created PyObject_GenericGetIter().Raymond Hettinger-9/+1
Factors out the common case of returning self.
2003-01-29Implement appropriate __getnewargs__ for all immutable subclassable builtinGuido van Rossum-1/+13
types. The special handling for these can now be removed from save_newobj(). Add some testing for this. Also add support for setting the 'fast' flag on the Python Pickler class, which suppresses use of the memo.
2002-10-11Add checks for size overflow on list*n, list+list, tuple+tuple.Guido van Rossum-0/+2
Will backport.