| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Minor wording fix.
|
|
|
|
|
|
|
| |
- Neatened the braces in PyList_New().
- Made sure "indexerr" was initialized to NULL.
- Factored if blocks in PyList_Append().
- Made sure "allocated" is initialized in list_init().
|
|
|
|
|
| |
Re-use list object bodies. Saves calls to malloc() and free() for
faster list instantiation and deallocation.
|
|
|
|
| |
dynamic embedders of Python.
|
|
|
|
|
|
| |
* Document the differences between them
* Fix corner cases covered by the unittests
* Use Py_RETURN_NONE where possible for dictionaries
|
| |
|
|
|
|
|
| |
* Applied app1() to listappend().
* Inlined ins() into its one remaining caller.
|
|
|
|
|
|
| |
steps and further improves the speed of list append.
* Add guards to the list iterator length method to handle corner cases.
|
|
|
|
| |
been used. (Suggested by Martin v. Loewis)
|
|
|
|
| |
attribute name lookup.
|
| |
|
|
|
|
|
|
|
|
| |
close() calls would attempt to free() the buffer already free()ed on
the first close(). [bug introduced with patch #788249]
Making sure that the buffer is free()ed in file object deallocation is
a belt-n-braces bit of insurance against a memory leak.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
off a new compiler wng under MSVC6).
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Fixes SF Bug #773356
|
| |
|
| |
|
|
|
|
|
| |
NULL in case of error, but the functions are declared to return int.
MSVC 6 properly complains about that. Return -1 on error instead.
|
|
|
|
| |
isinstance() or issubclass() to the recursion limit of the interpreter.
|
|
|
|
| |
'a.extend(a)' isn't so special anyway.
|
| |
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Py_USING_UNICODE is defined
|
| |
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
| |
|
|
|
|
|
| |
exact turned on. The tiny space savings wasn't worth the additional time
and code.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
(Spotted by Michael Hudson.)
* Now that "selflen" is no longer inside a loop, it should not be a
register variable.
|
|
|
|
|
| |
three recent optimizations. Aside from reducing code volume, it
increases readability.
|
|
|
|
|
|
|
| |
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).
|
|
|
|
| |
exposing _PyList_Extend().
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|