Commit Graph

2058 Commits

Author SHA1 Message Date
Tim Peters 7049d816fb Revert change accidentally checked in as part of a whitespace normalization
patch.
2004-01-18 20:31:02 +00:00
Tim Peters 58eb11cf62 Whitespace normalization. 2004-01-18 20:29:55 +00:00
Skip Montanaro ce59c04127 Remove support for SunOS 4.
Remove BAD_EXEC_PROTOYPE (leftover from IRIX 4 demolition).
2004-01-17 14:19:44 +00:00
Raymond Hettinger 2fb702966c SF Patch #871704: Py_SequenceFast can mask errors
(Contributed by Greg Chapman.)

Since this only changes the error message, I doubt that it should be
backported.
2004-01-11 23:26:51 +00:00
Hye-Shik Chang 75c00efcc7 [SF #866875] Add a specialized routine for one character
separaters on str.split() and str.rsplit().
2004-01-05 00:29:51 +00:00
Raymond Hettinger b86269db45 Apply pre-sizing optimization to a broader class of objects.
Formerly, the length was only fetched from sequence objects.
Now, any object that reports its length can benefit from pre-sizing.
2004-01-04 11:00:08 +00:00
Raymond Hettinger 7832cd6141 Apply tuple/list pre-sizing optimization to a broader class of objects.
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.
2004-01-04 06:08:16 +00:00
Hye-Shik Chang 1bc09b7c2a Cosmetic fix for wrongly indented tabs with ts=4. 2004-01-03 19:35:43 +00:00
Raymond Hettinger a3b11e7fb3 * Simplify and speedup logic for tp_print.
* Speed-up intersection whenever PyDict_Next can be used.
2003-12-31 14:08:58 +00:00
Hye-Shik Chang 7db07e6972 Fix gcc 3.3 warnings related to Py_UNICODE_WIDE. 2003-12-29 01:36:01 +00:00
Andrew MacIntyre f1ca7f561c complete backout of listobject.c v2.171 2003-12-28 07:43:56 +00:00
Jeremy Hylton 30973414c5 Revert previous two checkins to repair test failure.
The special-case code that was removed could return a value indicating
success but leave an exception set.  test_fileinput failed in a debug
build as a result.
2003-12-26 19:05:04 +00:00
Andrew MacIntyre 694e3a4a9d use the correct macro to access list size 2003-12-26 00:09:04 +00:00
Andrew MacIntyre d57caed52c Performance of list([]) in 2.3 came up in a thread on comp.lang.python,
which can be reviewed via
http://coding.derkeiler.com/Archive/Python/comp.lang.python/2003-12/1011.html

Duncan Booth investigated, and discovered that an "optimisation" was
in fact a pessimisation for small numbers of elements in a source list,
compared to not having the optimisation, although with large numbers
of elements in the source list the optimisation was quite beneficial.

He posted his change to comp.lang.python (but not to SF).

Further research has confirmed his assessment that the optimisation only
becomes a net win when the source list has more than 100 elements.

I also found that the optimisation could apply to tuples as well,
but the gains only arrive with source tuples larger than about 320
elements and are nowhere near as significant as the gains with lists,
(~95% gain @ 10000 elements for lists, ~20% gain @ 10000 elements for
tuples) so I haven't proceeded with this.

The code as it was applied the optimisation to list subclasses as
well, and this also appears to be a net loss for all reasonable sized
sources (~80-100% for up to 100 elements, ~20% for more than 500
elements; I tested up to 10000 elements).

Duncan also suggested special casing empty lists, which I've extended
to all empty sequences.

On the basis that list_fill() is only ever called with a list for the
result argument, testing for the source being the destination has
now happens before testing source types.
2003-12-25 13:28:48 +00:00
Hye-Shik Chang 7fc4cf57b8 Fix unicode.rsplit()'s bug that ignores separater on the end of string when
using specialized splitter for 1 char sep.
2003-12-23 09:10:16 +00:00
Skip Montanaro ac4ea13a3a There are places in Python which assume bytes have 8-bits. Formalize that a
bit by checking the value of UCHAR_MAX in Include/Python.h.  There was a
check in Objects/stringobject.c.  Remove that.  (Note that we don't define
UCHAR_MAX if it's not defined as the old test did.)
2003-12-22 16:31:41 +00:00
Hye-Shik Chang 40e9509dc7 Fix broken xmlcharrefreplace by rev 2.204.
(Pointy hat goes to perky)
2003-12-22 01:31:13 +00:00
Hye-Shik Chang 4a264fb054 SF #859573: Reduce compiler warnings on gcc 3.2 and above. 2003-12-19 01:59:56 +00:00
Raymond Hettinger 64958a15d7 Guido grants a Christmas wish:
sorted() becomes a regular function instead of a classmethod.
2003-12-17 20:43:33 +00:00
Raymond Hettinger 81ad32e435 Speedup set.update by using the override mode for PyDict_Merge(). 2003-12-15 21:16:06 +00:00
Hye-Shik Chang 3ae811b57d Add rsplit method for str and unicode builtin types.
SF feature request #801847.
Original patch is written by Sean Reifschneider.
2003-12-15 18:49:53 +00:00
Raymond Hettinger fb4e33a8e2 Improve algorithm for set.difference when the input is not a set. 2003-12-15 13:23:55 +00:00
Raymond Hettinger 438e02dfc8 * Refactor set.__contains__()
* Use Py_RETURN_NONE everywhere.
* Fix-up the firstpass check for the tp_print slot.
2003-12-13 19:38:47 +00:00
Raymond Hettinger 0deab62704 Refactor set.discard() and set.remove(). 2003-12-13 18:53:18 +00:00
Raymond Hettinger 6a8bbdbe7b Improve argument checking speed. 2003-12-13 15:21:55 +00:00
Raymond Hettinger dc5ae11abf Use dictionary specific looping idiom where possible.
Simplifies and speeds-up the code.
2003-12-13 14:46:46 +00:00
Raymond Hettinger 0c66967e3d Simplify previous checkin -- a new function was not needed. 2003-12-13 13:31:55 +00:00
Raymond Hettinger d3ae6729e7 Use PyDict_Contains() instead of PySequence_Contains(). 2003-12-13 11:58:56 +00:00
Raymond Hettinger 8f5cdaa784 * Added a new method flag, METH_COEXIST.
* Used the flag to optimize set.__contains__(), dict.__contains__(),
  dict.__getitem__(), and list.__getitem__().
2003-12-13 11:26:12 +00:00
Hye-Shik Chang 19cb193244 Fix memory error treatment correctly. Going to dsu_fail causes
deallocating garbage pointers; saved_ob_item and empty_ob_item.
(Reviewed by Raymond Hettinger)
2003-12-10 07:31:08 +00:00
Michael W. Hudson 1df0f654e8 Fixes and tests for various "holding pointers when arbitrary Python code
can run" bugs as discussed in

[ 848856 ] couple of new list.sort bugs
2003-12-04 11:25:46 +00:00
Guido van Rossum 6c9e130524 - Removed FutureWarnings related to hex/oct literals and conversions
and left shifts.  (Thanks to Kalle Svensson for SF patch 849227.)
  This addresses most of the remaining semantic changes promised by
  PEP 237, except for repr() of a long, which still shows the trailing
  'L'.  The PEP appears to promise warnings for operations that
  changed semantics compared to Python 2.3, but this is not
  implemented; we've suffered through enough warnings related to
  hex/oct literals and I think it's best to be silent now.
2003-11-29 23:52:13 +00:00
Raymond Hettinger 37e136373e Make sure the list.sort's decorate step unwinds itself before returning
an exception raised by the key function.
(Suggested by Michael Hudson.)
2003-11-28 21:43:02 +00:00
Raymond Hettinger 4f8f976576 Add optional fillchar argument to ljust(), rjust(), and center() string methods. 2003-11-26 08:21:35 +00:00
Raymond Hettinger bc0f2ab9bb Expose dict_contains() and PyDict_Contains() with is about 10% faster
than PySequence_Contains() and more clearly applicable to dicts.

Apply the new function in setobject.c where __contains__ checking is
ubiquitous.
2003-11-25 21:12:14 +00:00
Raymond Hettinger a38123e2fa Factor out more duplicate code. 2003-11-24 22:18:49 +00:00
Guido van Rossum 5f4e45d66f Stop GCC warning about int literal that's so long that it becomes an
unsigned int (on a 32-bit machine), by adding an explicit 'u' to the
literal (a prime used to improve the hash function for frozenset).
2003-11-24 04:13:13 +00:00
Raymond Hettinger f5f41bf087 * Checkin remaining documentation
* Add more tests
* Refactor and neaten the code a bit.
* Rename union_update() to update().
* Improve the algorithms (making them a closer to sets.py).
2003-11-24 02:57:33 +00:00
Raymond Hettinger 49ba4c39c4 * Simplify hash function and add test to show effectiveness of the hash
function.

* Add a better test for deepcopying.

* Add tests to show the __init__() function works like it does for list
  and tuple.  Add related test.

* Have shallow copies of frozensets return self.  Add related test.

* Have frozenset(f) return f if f is already a frozenset. Add related test.

* Beefed-up some existing tests.
2003-11-23 02:49:05 +00:00
Guido van Rossum baf0f8f24d - When method objects have an attribute that can be satisfied either
by the function object or by the method object, the function
  object's attribute usually wins.  Christian Tismer pointed out that
  that this is really a mistake, because this only happens for special
  methods (like __reduce__) where the method object's version is
  really more appropriate than the function's attribute.  So from now
  on, all method attributes will have precedence over function
  attributes with the same name.
2003-11-22 23:55:50 +00:00
Raymond Hettinger bfd334a42d Extend temporary hashability to remove() and discard().
Brings the functionality back in line with sets.py.
2003-11-22 03:55:23 +00:00
Raymond Hettinger 19c2d77842 Allow temporary hashability for the __contains__ test.
(Requested by Alex Martelli.)
2003-11-21 18:36:54 +00:00
Raymond Hettinger 3fbec701ca issubset() and issuperset() to work with general iterables 2003-11-21 07:56:36 +00:00
Raymond Hettinger 82d73dd459 Three minor performance improvements:
* Improve the hash function to increase the chance that distinct sets will
  have distinct xor'd hash totals.

* Use PyDict_Merge where possible (it is faster than an equivalent iter/set
  pair).

* Don't rebuild dictionaries where the input already has one.
2003-11-20 22:54:33 +00:00
Tim Peters 403a203223 SF bug 839548: Bug in type's GC handling causes segfaults.
Also SF patch 843455.

This is a critical bugfix.
I'll backport to 2.3 maint, but not beyond that.  The bugs this fixes
have been there since weakrefs were introduced.
2003-11-20 21:21:46 +00:00
Jack Jansen eddc1449ba Getting rid of all the code inside #ifdef macintosh too. 2003-11-20 01:44:59 +00:00
Jack Jansen 4bae2d5e46 Getting rid of code dependent on GUSI or the MetroWerks compiler. 2003-11-19 22:52:23 +00:00
Jack Jansen fb2765666f Getting rid of support for the ancient Apple MPW compiler. 2003-11-19 15:24:47 +00:00
Guido van Rossum b61982bacb Implement straightforward suggestions from gcc warnings (remove unused
variable, add extra braces).
2003-11-18 19:27:19 +00:00
Raymond Hettinger 1b92fd5bca Use PySequence_Contains() instead of direct access macro. 2003-11-18 14:15:31 +00:00