summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Intern __name__.Martin v. Löwis2004-03-231-1/+9
|
* Restored revision 2.87.Armin Rigo2004-03-211-12/+5
|
* PyTuple_New(): vrbl i no longer referenced, so removed it (which killsTim Peters2004-03-211-1/+1
| | | | off a new compiler wng under MSVC6).
* This is the fastest I could get on Intel GCC. I kept the memset() in to clearArmin Rigo2004-03-211-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.
* Changed file.name to be the object passed as the 'name' argument to file()Nicholas Bastin2004-03-211-17/+21
| | | | Fixes SF Bug #773356
* Fix typo in comment.Raymond Hettinger2004-03-211-1/+1
|
* Add identity shortcut to PyObject_RichCompareBool.Raymond Hettinger2004-03-211-1/+11
|
* recursive_isinstance(), recursive_issubclass(): New code here returnedTim Peters2004-03-211-2/+2
| | | | | NULL in case of error, but the functions are declared to return int. MSVC 6 properly complains about that. Return -1 on error instead.
* Limit the nesting depth of a tuple passed as the second argument toBrett Cannon2004-03-201-9/+36
| | | | isinstance() or issubclass() to the recursion limit of the interpreter.
* Get rid of listextend_internal() and explain why the special caseArmin Rigo2004-03-201-51/+25
| | | | 'a.extend(a)' isn't so special anyway.
* memset() hunt continuing. This is a net win.Armin Rigo2004-03-201-1/+3
|
* memset() with small memory sizes just kill us.Armin Rigo2004-03-201-2/+4
|
* GCC was complaining that 'value' in dictiter_iternextvalue() wasn'tGuido van Rossum2004-03-201-5/+6
| | | | | | necessarily always set before used. Between Tim, Armin & me we couldn't prove GCC wrong, so we decided to fix the algorithm. This version is Armin's.
* PyFile_WriteObject(): some of the local variables are only used whenFred Drake2004-03-191-0/+2
| | | | Py_USING_UNICODE is defined
* Factor out a double lookup.Raymond Hettinger2004-03-191-2/+1
|
* Make iterators length transparent where possible.Raymond Hettinger2004-03-183-3/+42
|
* Make the new dictionary iterators transparent with respect to length.Raymond Hettinger2004-03-181-4/+20
| | | | | | This gives another 30% speedup for operations such as map(func, d.iteritems()) or list(d.iteritems()) which can both take advantage of length information when provided.
* Optimize dictionary iterators.Raymond Hettinger2004-03-181-57/+202
| | | | | | | | | | | | | | | | | | * Split into three separate types that share everything except the code for iternext. Saves run time decision making and allows each iternext function to be specialized. * Inlined PyDict_Next(). In addition to saving a function call, this allows a redundant test to be eliminated and further specialization of the code for the unique needs of each iterator type. * Created a reusable result tuple for iteritems(). Saves the malloc time for tuples when the previous result was not kept by client code (this is the typical use case for iteritems). If the client code does keep the reference, then a new tuple is created. Results in a 20% to 30% speedup depending on the size and sparsity of the dictionary.
* Dictionary optimizations:Raymond Hettinger2004-03-171-24/+61
| | | | | | | | | | | | * Factored constant structure references out of the inner loops for PyDict_Next(), dict_keys(), dict_values(), and dict_items(). Gave measurable speedups to each (the improvement varies depending on the sparseness of the dictionary being measured). * Added a freelist scheme styled after that for tuples. Saves around 80% of the calls to malloc and free. About 10% of the time, the previous dictionary was completely empty; in those cases, the dictionary initialization with memset() can be skipped.
* Add missing decrefRaymond Hettinger2004-03-171-0/+1
|
* Fix typos and add some elaborationsRaymond Hettinger2004-03-151-4/+9
|
* Revert last change. Found an application that was worse off with resizeRaymond Hettinger2004-03-151-13/+10
| | | | | exact turned on. The tiny space savings wasn't worth the additional time and code.
* Eliminate an unnecessary test on a common code path.Raymond Hettinger2004-03-151-3/+1
|
* list_resize() now has an "exact" option for bypassing the overallocationRaymond Hettinger2004-03-141-10/+13
| | | | | | | | | | | | | | | | | | scheme in situations that likely won't benefit from it. This further improves memory utilization from Py2.3 which always over-allocates except for PyList_New(). Situations expected to benefit from over-allocation: list.insert(), list.pop(), list.append(), and list.extend() Situations deemed unlikely to benefit: list_inplace_repeat, list_ass_slice, list_ass_subscript The most gray area was for listextend_internal() which only runs when the argument is a list or a tuple. This could be viewed as a one-time fixed length addition or it could be viewed as wrapping a series of appends. I left its over-allocation turned on but could be convinced otherwise.
* Make PySequence_Fast_ITEMS public. (Thanks Skip.)Raymond Hettinger2004-03-121-3/+3
|
* * 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.