summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
Commit message (Collapse)AuthorAgeFilesLines
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-10/+10
| | | | | | | 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.
* Some style nits. Also clarify in the docstrings what __sizeof__ does.Georg Brandl2008-06-011-1/+1
|
* Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.Robert Schuppenies2008-06-011-0/+12
|
* Renamed PyString to PyBytesChristian Heimes2008-05-261-10/+10
|
* A little reformating of Py3k warningsBenjamin Peterson2008-04-271-1/+1
|
* Use PyErr_WarnPy3k throughoutBenjamin Peterson2008-04-271-3/+1
|
* Make Py3k warnings consistent w.r.t. punctuation; also respect theGeorg Brandl2008-03-251-1/+1
| | | | EOL 80 limit and supply more alternatives in warning messages.
* Issue 2354: Fix-up compare warning. Patch contributed by Jeff Balogh.Raymond Hettinger2008-03-191-1/+1
|
* Issue: 2354: Add 3K warning for the cmp argument to list.sort() and sorted().Raymond Hettinger2008-03-181-0/+5
|
* Use PY_FORMAT_SIZE_T instead of z for string formatting. Thanks Neal.Christian Heimes2008-02-241-2/+4
|
* Use prefix decrementChristian Heimes2008-02-081-2/+1
|
* Added some statistics code to dict and list object code. I wanted to test ↵Christian Heimes2008-02-071-0/+29
| | | | how a larger freelist affects the reusage of freed objects. Contrary to my gut feelings 80 objects is more than fine for small apps. I haven't profiled a large app yet.
* Unified naming convention for free lists and their limits. All free listsChristian Heimes2008-02-061-11/+13
| | | | | | | | 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.
* Use the right (portable) definition of the max of a Py_ssize_t.Thomas Wouters2008-01-251-1/+1
|
* Rewrite the list_inline_repeat overflow check slightly differently.Guido van Rossum2008-01-251-6/+7
|
* #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes2007-12-191-83/+83
| | | | Py_REFCNT. Macros for b/w compatibility are available.
* Optimize PyList_AsTuple(). Improve cache performance by doing theRaymond Hettinger2007-12-151-5/+5
| | | | | | pointer copy and object increment in one pass. For small lists, save the overhead of the call to memcpy() -- this comes up in calls like f(*listcomp).
* Fix Issue 1045.Raymond Hettinger2007-12-061-11/+1
| | | | | Factor-out common calling code by simplifying the length_hint API. Speed-up the function by caching the PyObject_String for the attribute lookup.
* merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ ↵Christian Heimes2007-12-051-2/+3
| | | | can make list() raise a SystemError
* Backport of _abccoll.py by Benjamin Arangueren, issue 1383.Guido van Rossum2007-11-221-9/+1
| | | | With some changes of my own thrown in (e.g. backport of r58107).
* Fix the overflow checking of list_repeat.Armin Rigo2007-10-171-4/+7
| | | | | | Introduce overflow checking into list_inplace_repeat. Backport candidate, possibly.
* Add a bunch of GIL release/acquire points in tp_print implementations and forBrett Cannon2007-09-171-1/+10
| | | | | | PyObject_Print(). Closes issue #1164.
* Fix a possible segfault from recursing too deep to get the repr of a list.Brett Cannon2007-09-101-0/+3
| | | | Closes issue #1096.
* Improve extended slicing support in builtin types and classes. Specifically:Thomas Wouters2007-08-281-13/+30
| | | | | | | | | | | | | | | | | | | | - 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.
* PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis2007-07-211-92/+87
| | | | | backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
* Variation of patch # 1624059 to speed up checking if an object is a subclassNeal Norwitz2007-02-251-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.
* Patch [ 1586791 ] better error msgs for some TypeErrorsGeorg Brandl2006-11-191-6/+9
|
* Prevent crash if alloc of garbage fails. Found by Typo.pl.Neal Norwitz2006-10-281-0/+5
| | | | Will backport.
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-8/+3
| | | | | | | | | | | | | | | | | | | | | | | * unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests...
* Move initialization to after the asserts for non-NULL values.Neal Norwitz2006-08-191-2/+4
| | | | | | Klocwork 286-287. (I'm not backporting this, but if someone wants to, feel free.)
* Patch #1538606, Patch to fix __index__() clipping.Neal Norwitz2006-08-121-7/+5
| | | | | | | 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.
* Check return of PyMem_MALLOC (garbage) is non-NULL.Neal Norwitz2006-08-121-2/+6
| | | | | | Check seq in both portions of if/else. Klocwork #289-290.
* Don't leak the list object if there's an error allocating the item storage. ↵Neal Norwitz2006-06-121-1/+3
| | | | Backport candidate
* Remove now-unused variables from tp_traverse and tp_clear methods.Tim Peters2006-04-151-1/+0
|
* Use Py_VISIT in all tp_traverse methods, instead of traversing manually orThomas Wouters2006-04-151-14/+6
| | | | | | | | 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
* Replace INT_MAX with PY_SSIZE_T_MAX.Martin v. Löwis2006-04-131-2/+2
|
* More C++-compliance. Note especially listobject.c - to get C++ to accept theAnthony Baxter2006-04-111-81/+93
| | | | | | | | | PyTypeObject structures, I had to make prototypes for the functions, and move the structure definition ahead of the functions. I'd dearly like a better way to do this - to change this would make for a massive set of changes to the codebase. There's still some warnings - this is purely to get rid of errors first.
* Checking in the code for PEP 357.Guido van Rossum2006-03-071-10/+8
| | | | | | 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).
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-2/+2
|
* Use Py_ssize_t for counts and sizes.Martin v. Löwis2006-02-161-4/+4
| | | | Convert Py_ssize_t using PyInt_FromSsize_t
* Revert 42400.Martin v. Löwis2006-02-161-2/+2
|
* Support %zd in PyErr_Format and PyString_FromFormat.Martin v. Löwis2006-02-161-2/+1
|
* Get rid of compiler warnings (gcc 3.3.4 on x86)Neal Norwitz2006-02-161-2/+2
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-138/+136
|
* Renamed _length_cue() to __length_hint__(). See:Armin Rigo2006-02-111-3/+3
| | | | http://mail.python.org/pipermail/python-dev/2006-February/060524.html
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-2/+2
| | | | | | | | | | | | | | | | | | | 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 *.
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-14/+11
|
* SF bug #1242657: list(obj) can swallow KeyboardInterruptRaymond Hettinger2005-08-211-0/+5
| | | | | | Fix over-aggressive PyErr_Clear(). The same code fragment appears in various guises in list.extend(), map(), filter(), zip(), and internally in PySequence_Tuple().
* Finalize the freelist of list objects.Raymond Hettinger2004-10-071-0/+13
|
* Checkin Tim's fix to an error discussed on python-dev.Raymond Hettinger2004-09-261-10/+20
| | | | | | | | | | | | | | | | | Also, add a testcase. Formerly, the list_extend() code used several local variables to remember its state across iterations. Since an iteration could call arbitrary Python code, it was possible for the list state to be changed. The new code uses dynamic structure references instead of C locals. So, they are always up-to-date. After list_resize() is called, its size has been updated but the new cells are filled with NULLs. These needed to be filled before arbitrary iteration code was called; otherwise, that code could attempt to modify a list that was in a semi-invalid state. The solution was to change the ob->size field back to a value reflecting the actual number of valid cells.