summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* * Eliminate duplicate call to PyObject_Size().Raymond Hettinger2004-03-121-3/+3
| | | | | | | (Spotted by Michael Hudson.) * Now that "selflen" is no longer inside a loop, it should not be a register variable.
* Use a new macro, PySequence_Fast_ITEMS to factor out code common toRaymond Hettinger2004-03-121-16/+3
| | | | | three recent optimizations. Aside from reducing code volume, it increases readability.
* Now that list.extend() is at the root of many list operations, it becomesRaymond Hettinger2004-03-111-3/+9
| | | | | | | worth it to in-line the call to PyIter_Next(). Saves another 15% on most list operations that acceptable a general iterable argument (such as the list constructor).
* Eliminate a big block of duplicate code in PySequence_List() byRaymond Hettinger2004-03-112-54/+12
| | | | exposing _PyList_Extend().
* list_inplace_concat() is now expressed in terms of list_extend() whichRaymond Hettinger2004-03-111-14/+13
| | | | | | | | avoids creating an intermediate tuple for iterable arguments other than lists or tuples. In other words, a+=b no longer requires extra memory when b is not a list or tuple. The list and tuple cases are unchanged.
* Make buffer objects based on mutable objects (like array) safe.Neil Schemenauer2004-03-111-82/+149
|
* Document one of the many problems with the buffer object.Neil Schemenauer2004-03-111-2/+9
|
* Rename static functions, they should not have the _Py prefix.Neil Schemenauer2004-03-111-11/+10
|
* Use memcpy() instead of memmove() when the buffers are known to be distinct.Raymond Hettinger2004-03-101-2/+2
|
* Tidied up the implementations of reversed (including the custom onesRaymond Hettinger2004-03-103-26/+56
| | | | | | | | | | | | | | | | | for xrange and list objects). * list.__reversed__ now checks the length of the sequence object before calling PyList_GET_ITEM() because the mutable could have changed length. * all three implementations are now tranparent with respect to length and maintain the invariant len(it) == len(list(it)) even when the underlying sequence mutates. * __builtin__.reversed() now frees the underlying sequence as soon as the iterator is exhausted. * the code paths were rearranged so that the most common paths do not require a jump.
* Eliminate the double reverse option. It's only use caseRaymond Hettinger2004-03-101-13/+1
| | | | was academic and it was potentially confusing to use.
* Optimize inner loops for subscript, repeat, and concat.Raymond Hettinger2004-03-092-36/+59
|
* Optimize slice assignments.Raymond Hettinger2004-03-091-16/+17
| | | | | | | | | | | | | * Replace sprintf message with a constant message string -- this error message ran on every invocation except straight deletions but it was only needed when the rhs was not iterable. The message was also out-of-date and did not reflect that iterable arguments were allowed. * For inner loops that do not make ref count adjustments, use memmove() for fast copying and better readability. * For inner loops that do make ref count adjustments, speed them up by factoring out the constant structure reference and using vitem[] instead.
* The copy module now handles sets directly. The __copy__ methods are noRaymond Hettinger2004-03-081-4/+0
| | | | longer needed.
* Optimize tuple_slice() and make further improvements to list_slice()Raymond Hettinger2004-03-082-18/+25
| | | | | | and list.extend(). Factoring the inner loops to remove the constant structure references and fixed offsets gives speedups ranging from 20% to 30%.
* Small optimizations for list_slice() and list_extend_internal().Raymond Hettinger2004-03-081-9/+20
| | | | | | | | * Using addition instead of substraction on array indices allows the compiler to use a fast addressing mode. Saves about 10%. * Using PyTuple_GET_ITEM and PyList_SET_ITEM is about 7% faster than PySequenceFast_GET_ITEM which has to make a list check on every pass.
* Factor out code common to PyDict_Copy() and PyDict_Merge().Raymond Hettinger2004-03-081-20/+6
|
* SF #904720: dict.update should take a 2-tuple sequence like dict.__init_Raymond Hettinger2004-03-041-18/+24
| | | | | | | | (Championed by Bob Ippolito.) The update() method for mappings now accepts all the same argument forms as the dict() constructor. This includes item lists and/or keyword arguments.
* Oops, didn't mean to commit the removal of float_compare!Michael W. Hudson2004-02-261-1/+1
|
* Pass a variable that actually exists to PyFPE_END_PROTECT inMichael W. Hudson2004-02-261-2/+2
| | | | float_richcompare. Reported on c.l.py by Helmut Jarausch.
* "Fix" (for certain configurations of the planets, includingMichael W. Hudson2004-02-191-1/+35
| | | | | | | | | | | recent gcc on Linux/x86) [ 899109 ] 1==float('nan') by implementing rich comparisons for floats. Seems to make comparisons involving NaNs somewhat less surprising when the underlying C compiler actually implements C99 semantics.
* Keep the list.pop() optimization while restoring the many possibilityRaymond Hettinger2004-02-191-4/+2
| | | | | for types other than PyInt being accepted for the optional argument. (Spotted by Neal Norwitz.)
* Oops. Return -1 to distinguish error from empty dict.Jeremy Hylton2004-02-171-1/+1
| | | | | This change probably isn't work a bug fix. It's unlikely that anyone was calling this method without passing it a real dict.
* Double the speed of list.pop() which was spending most of its time parsingRaymond Hettinger2004-02-171-2/+11
| | | | arguments.
* Refactor list_extend() and list_fill() for gains in code size, memoryRaymond Hettinger2004-02-151-84/+71
| | | | | | | | | | | | | | | | | | | | | | | | utilization, and speed: * Moved the responsibility for emptying the previous list from list_fill to list_init. * Replaced the code in list_extend with the superior code from list_fill. * Eliminated list_fill. Results: * list.extend() no longer creates an intermediate tuple except to handle the special case of x.extend(x). The saves memory and time. * list.extend(x) runs 5 to 10% faster when x is a list or tuple 15% faster when x is an iterable not defining __len__ twice as fast when x is an iterable defining __len__ * the code is about 15 lines shorter and no longer duplicates functionality.
* Fine tune the speed/space trade-off for overallocating small lists.Raymond Hettinger2004-02-141-8/+3
| | | | | | | | | | | | | | The Py2.3 approach overallocated small lists by up to 8 elements. The last checkin would limited this to one but slowed down (by 20 to 30%) the creation of small lists between 3 to 8 elements. This tune-up balances the two, limiting overallocation to 3 elements (significantly reducing space consumption from Py2.3) and running faster than the previous checkin. The first part of the growth pattern (0, 4, 8, 16) neatly meshes with allocators that trigger data movement only when crossing a power of two boundary. Also, then even numbers mesh well with common data alignments.
* Fix missing return value. Spotted by Neal NorwitzRaymond Hettinger2004-02-141-0/+1
|
* Optimize list.pop() for the common special case of popping off the end.Raymond Hettinger2004-02-131-0/+5
| | | | More than doubles its speed.
* * Optimized list appends and pops by making fewer calls the underlying systemRaymond Hettinger2004-02-131-89/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | realloc(). This is achieved by tracking the overallocation size in a new field and using that information to skip calls to realloc() whenever possible. * Simplified and tightened the amount of overallocation. For larger lists, this overallocates by 1/8th (compared to the previous scheme which ranged between 1/4th to 1/32nd over-allocation). For smaller lists (n<6), the maximum overallocation is one byte (formerly it could be upto eight bytes). This saves memory in applications with large numbers of small lists. * Eliminated the NRESIZE macro in favor of a new, static list_resize function that encapsulates the resizing logic. Coverting this back to macro would give a small (under 1%) speed-up. This was too small to warrant the loss of readability, maintainability, and de-coupling. * Some functions using NRESIZE had grown unnecessarily complex in their efforts to bend to the macro's calling pattern. With the new list_resize function in place, those other functions could be simplified. That is being saved for a separate patch. * The ob_item==NULL check could be eliminated from the new list_resize function. This would entail finding each piece of code that sets ob_item to NULL and adding a new line to invalidate the overallocation tracking field. Rather than impose a new requirement on other pieces of list code, it was preferred to leave the NULL check in place and retain the benefits of decoupling, maintainability and information hiding (only PyList_New() and list_sort() need to know about the new field). This approach also reduces the odds of breaking an extension module. (Collaborative effort by Raymond Hettinger, Hye-Shik Chang, Tim Peters, and Armin Rigo.)
* Make reversed() transparent with respect to length.Raymond Hettinger2004-02-101-1/+13
|
* SF patch #875689: >100k alloc wasted on startupRaymond Hettinger2004-02-081-1/+1
| | | | | | | (Contributed by Mike Pall.) Make sure fill_free_list() is called only once rather than 106 times when pre-allocating small ints.
* Let reversed() work with itself.Raymond Hettinger2004-02-081-1/+12
|
* Fixed a bug in object.__reduce_ex__ (reduce_2) when using protocolJim Fulton2004-02-081-0/+1
| | | | | 2. Failure to clear the error when attempts to get the __getstate__ attribute fail caused intermittent errors and odd behavior.
* Remove support for --without-universal-newlines (see PEP 11).Skip Montanaro2004-02-071-35/+0
|
* * Fix ref counting in extend() and extendleft().Raymond Hettinger2004-02-071-2/+1
| | | | * Let deques support reversed().
* Fix reallocation bug in unicode.translate(): The code was comparingWalter Dörwald2004-02-051-1/+1
| | | | characters instead of character pointers to determine space requirements.
* Allocating a new weakref object can cause existing weakref objects forFred Drake2004-02-041-3/+16
| | | | | | | | | the same object to be collected by the cyclic GC support if they are only referenced by a cycle. If the weakref being collected was one of the weakrefs without callbacks, some local variables for the constructor became invalid and have to be re-computed. The test caused a segfault under a debug build without the fix applied.
* Fix bug in interpretation of the "callback" argument in the constructors forFred Drake2004-02-031-1/+5
| | | | | weakref ref and proxy objects; None was not being treated as identical to NULL, though it was documented as equivalent.
* Removed two unneeded lines from PyObject_Compare().Brett Cannon2004-01-271-2/+0
| | | | Closes bug #885293 (thanks, Josiah Carlson).
* Two forgotten Py_DECREF() for two out-of-memory conditions.Armin Rigo2004-01-271-2/+6
|
* Revert change accidentally checked in as part of a whitespace normalizationTim Peters2004-01-181-9/+5
| | | | patch.
* Whitespace normalization.Tim Peters2004-01-181-5/+9
|
* Remove support for SunOS 4.Skip Montanaro2004-01-171-10/+0
| | | | Remove BAD_EXEC_PROTOYPE (leftover from IRIX 4 demolition).
* SF Patch #871704: Py_SequenceFast can mask errorsRaymond Hettinger2004-01-111-3/+11
| | | | | | | (Contributed by Greg Chapman.) Since this only changes the error message, I doubt that it should be backported.
* [SF #866875] Add a specialized routine for one characterHye-Shik Chang2004-01-051-45/+95
| | | | separaters on str.split() and str.rsplit().
* Apply pre-sizing optimization to a broader class of objects.Raymond Hettinger2004-01-041-8/+4
| | | | | Formerly, the length was only fetched from sequence objects. Now, any object that reports its length can benefit from pre-sizing.
* Apply tuple/list pre-sizing optimization to a broader class of objects.Raymond Hettinger2004-01-042-9/+5
| | | | | | | | Formerly, length data fetched from sequence objects. Now, any object that reports its length can benefit from pre-sizing. On one sample timing, it gave a threefold speedup for list(s) where s was a set object.
* Cosmetic fix for wrongly indented tabs with ts=4.Hye-Shik Chang2004-01-031-8/+8
|
* * Simplify and speedup logic for tp_print.Raymond Hettinger2003-12-311-15/+29
| | | | * Speed-up intersection whenever PyDict_Next can be used.
* Fix gcc 3.3 warnings related to Py_UNICODE_WIDE.Hye-Shik Chang2003-12-291-1/+4
|