Commit Graph

23981 Commits

Author SHA1 Message Date
Fred Drake e20131efc3 Fix a couple of whitespace consistency nits. 2002-08-26 21:20:30 +00:00
Fred Drake 6049cb8918 Simplify, and avoid PyModule_GetDict() while we're at it. 2002-08-26 21:15:11 +00:00
Barry Warsaw da5628f286 Fix an inaccuracy in the comment 2002-08-26 16:44:56 +00:00
Tim Peters 454602f0f7 Gave intersection_update a speed boost. 2002-08-26 00:44:07 +00:00
Tim Peters cd06eeb20c Gave issubet() and issuperset() major speed boosts. That's it for now!
Someone else may want to tackle the mutating operations similarly.
2002-08-25 20:12:19 +00:00
Tim Peters b8940393e9 Gave __sub__/difference a factor of 2-5 speed boost. 2002-08-25 19:50:43 +00:00
Tim Peters 334b4a5c39 Gave __xor__/symmetric_difference a factor of 2-5 speed boost. 2002-08-25 19:47:54 +00:00
Tim Peters 37faed2532 Sped union by a factor of 3-4. 2002-08-25 19:21:27 +00:00
Tim Peters d33e6be59d Sped intersection by large factors (3-5x faster than before on sets of
cardinality 500; and the smaller the intersection, the bigger the speedup).
2002-08-25 19:12:45 +00:00
Tim Peters 4a2f91e302 Added a clue about why xyz_update isn't the same as __xyz__. 2002-08-25 18:59:04 +00:00
Tim Peters ea76c98014 Implemented <, <=, >, >= for sets, giving subset and proper-subset
meanings.  I did not add new, e.g., ispropersubset() methods; we're
going nuts on those, and, e.g., there was no "friendly name" for
== either.
2002-08-25 18:43:10 +00:00
Tim Peters 93d8d48c15 TestSubset(): Generalized the framework to support testing upcoming
<, <=, etc methods too.
2002-08-25 18:21:47 +00:00
Tim Peters 4127e91d20 Rewrote all remaining assert stmts. 2002-08-25 18:02:29 +00:00
Tim Peters 62c62438ff Simplified construction of the test suite. 2002-08-25 17:49:04 +00:00
Tim Peters de830ca4eb Simplified code building sets of characters. 2002-08-25 17:40:29 +00:00
Tim Peters a777799040 Ack! Virtually every test here relied on an assert stmt. assert stmts
should never be used in tests.  Repaired dozens, but more is needed.
2002-08-25 17:38:49 +00:00
Tim Peters 0bbb30830c Simplified the setup for is-subset testing. 2002-08-25 17:22:23 +00:00
Tim Peters 4924db176b Record a clue about why __or__ is not union, etc. 2002-08-25 17:10:17 +00:00
Raymond Hettinger c8f8034512 Replace 0 with False to match working in documentation. SF 599681. 2002-08-25 16:36:49 +00:00
Raymond Hettinger 7ad09552d0 Correct documentation of allow_reuse_address to match the actual script.
Closes SF bug 599681.
2002-08-25 16:27:33 +00:00
Kurt B. Kaiser adc63847e4 1. Revert subprocess environment clearing, will restart subprocess
instead.
2. Preserve the Idle client's listening socket for reuse with the
   fresh subprocess.
3. Remove some unused rpc code, comment out additional unused code.

Modified Files:
ScriptBinding.py rpc.py run.py
2002-08-25 14:08:07 +00:00
Kurt B. Kaiser a552e3a0c9 Improve exception handling across rpc interface
Modified Files:
 	rpc.py
2002-08-24 23:57:17 +00:00
Raymond Hettinger e87ab3fefe Removed < <= > >= from the API. Implemented as comparisons of the
underlying dictionaries, there were no reasonable use cases (lexicographic
sorting of a list of sets is somewhat esoteric).  Frees the operators
for other uses (such as strict subset and superset comparisons).

Updated documentation and test suite accordingly.
2002-08-24 07:33:06 +00:00
Guido van Rossum bf935fde15 string_contains(): speed up by avoiding function calls where
possible.  This always called PyUnicode_Check() and PyString_Check(),
at least one of which would call PyType_IsSubtype().  Also, this would
call PyString_Size() on known string objects.
2002-08-24 06:57:49 +00:00
Guido van Rossum 9d6897accc Speed up the most egregious "if token in (long tuple)" cases by using
a dict instead.  (Alas, using a Set would be slower instead of
faster.)
2002-08-24 06:54:19 +00:00
Guido van Rossum 6248f441ea Speedup for PyObject_IsTrue(): check for True and False first.
Because all built-in tests return bools now, this is the most common
path!
2002-08-24 06:31:34 +00:00
Raymond Hettinger 1b9f5d4c1a At Tim Peter's suggestion, propagated GvR's binary operator changes to
the inplace operators.  The strategy is to have the operator overloading
code do the work and then to define equivalent method calls which rely on
the operators.  The changes facilitate proper application of TypeError
and NonImplementedErrors.

Added corresponding tests to the test suite to make sure both the operator
and method call versions get exercised.

Add missing tests for difference_update().
2002-08-24 06:19:02 +00:00
Guido van Rossum 81912d4764 Speedup for PyObject_RichCompareBool(): PyObject_RichCompare() almost
always returns a bool, so avoid calling PyObject_IsTrue() in that
case.
2002-08-24 05:33:28 +00:00
Raymond Hettinger d50185127f Since instances of _TemporarilyImmutableSet are always thrown away
immediately after the comparison, there in no use in caching the hashcode.
The test, 'if self._hashcode is None', never fails.  Removing the caching
saves a few lines and a little time.
2002-08-24 04:47:42 +00:00
Raymond Hettinger 045e51a9a5 Expanded tests for sets of sets. 2002-08-24 02:56:01 +00:00
Raymond Hettinger fa1480f686 1. Removed module self test in favor of unittests -- Timbot's suggestion.
2. Replaced calls to Set([]) with Set() -- Timbot's suggestion
3. Fixed subtle bug in sets of sets:

The following code did not work (will add to test suite):
    d = Set('d')
    s = Set([d])  # Stores inner set as an ImmutableSet
    s.remove(d)   # For comparison, wraps d in _TemporarilyImmutableSet

The comparison proceeds by computing the hash of the
_TemporarilyImmutableSet and finding it in the dictionary.
It then verifies equality by calling ImmutableSet.__eq__()
and crashes from the binary sanity check.

The problem is that the code assumed equality would be checked
with _TemporarilyImmutableSet.__eq__().

The solution is to let _TemporarilyImmutableSet derive from BaseSet
so it will pass the sanity check and then to provide it with the
._data element from the wrapped set so that ImmutableSet.__eq__()
will find ._data where it expects.

Since ._data is now provided and because BaseSet is the base class,
_TemporarilyImmutableSet no longer needs .__eq__() or .__ne__().

Note that inheriting all of BaseSet's methods is harmless because
none of those methods (except ones starting with an underscore)
can mutate the .data element.  Also _TemporarilyImmutableSet is only
used internally as is not otherwise visible.
2002-08-24 02:35:48 +00:00
Fred Drake 055be47b43 Fix typo reported to python-docs. 2002-08-23 21:19:53 +00:00
Tim Peters 53506be258 pop() docstring: this isn't a randomly-chosen element, it's merely
arbitrary.  I already changed the docs for this.
2002-08-23 20:36:58 +00:00
Tim Peters d06d03041b Comment repair. 2002-08-23 20:06:42 +00:00
Guido van Rossum 2023c9b84a Fix SF bug 599128, submitted by Inyeol Lee: .replace() would do the
wrong thing for a unicode subclass when there were zero string
replacements.  The example given in the SF bug report was only one way
to trigger this; replacing a string of length >= 2 that's not found is
another.  The code would actually write outside allocated memory if
replacement string was longer than the search string.

(I wonder how many more of these are lurking?  The unicode code base
is full of wonders.)

Bugfix candidate; this same bug is present in 2.2.1.
2002-08-23 18:50:21 +00:00
Guido van Rossum 8b1a6d694f Code by Inyeol Lee, submitted to SF bug 595350, to implement
the string/unicode method .replace() with a zero-lengt first argument.
Inyeol contributed tests for this too.
2002-08-23 18:21:28 +00:00
Tim Peters 280488b9a3 Whitespace normalization. 2002-08-23 18:19:30 +00:00
Raymond Hettinger fa8dd5f407 Fix markup and punctuation 2002-08-23 18:10:54 +00:00
Tim Peters 7c7efe9073 Got rid of the toy _Set class, in favor of sets.Set. 2002-08-23 17:55:54 +00:00
Tim Peters b81b252fab s/_as_Temporarily_Immutable/_as_temporarily_immutable/g, because the
latter is what the code actually does.
2002-08-23 17:48:23 +00:00
Tim Peters 54fd3e6ffc pop(): An arbitrary element is removed, not a random element. 2002-08-23 17:45:43 +00:00
Fred Drake d10c6c949a Adjust the markup in a few places so this will actually format.
Remove the third column in the tables since it isn't used.
2002-08-23 17:22:36 +00:00
Fred Drake d526011091 Add an entry for the sets module documentation.
Move another entry so the boilerplate doesn't get mixed up with
document-specific content.
2002-08-23 15:38:02 +00:00
Raymond Hettinger 584cb198f7 Load docs for sets.py 2002-08-23 15:18:38 +00:00
Guido van Rossum e399d08a4a RH pointed out that discard(element) doesn't do the transformation on
the element if necessary.  Fixed by calling self.remove(element).
2002-08-23 14:45:02 +00:00
Guido van Rossum 86c659a329 The error messages in err_args() -- which is only called when the
required number of args is 0 or 1 -- were reversed.  Also change "1"
into "exactly one", the same words as used elsewhere for this
condition.
2002-08-23 14:11:35 +00:00
Jack Jansen b2628b0f37 Added the standard MacOSX location for documentation inside a framework
to the list of places where pydoc looks for HTML documents.
2002-08-23 08:40:42 +00:00
Guido van Rossum 040d7ca498 Rewritten using the tokenize module, which gives us a real tokenizer
rather than a number of approximating regular expressions.
Alas, it is 3-4 times slower.  Let that be a challenge for the
tokenize module.
2002-08-23 01:36:01 +00:00
Jack Jansen fd372aa8e9 Don't build ConfigurePythonCarbon and ConfigurePythonClassic any longer,
classic Python is gone.
2002-08-22 23:37:00 +00:00
Jack Jansen 5fd945895e For MacPython-OS9 verbose is the default. 2002-08-22 23:36:11 +00:00