summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-248-75/+111
|
* The key to the various sort columns got lost. Pulled fromSkip Montanaro2005-09-231-0/+10
| | | | http://mail.python.org/pipermail/python-dev/2002-July/026876.html
* - On 64-bit platforms, when __len__() returns a value that cannot beGuido van Rossum2005-09-202-2/+12
| | | | | | | represented as a C int, raise OverflowError. (Forward port from 2.4.2; the patch to classobject.c was already in but needed a correction in the error message text.)
* A minor fix for 64-bit platforms: when __len__() returns Python intGuido van Rossum2005-09-191-1/+11
| | | | | | containing a value that doesn't fit in a C int, raise OverflowError rather than truncating silently (and having 50% chance of hitting the "it should be >= 0" error).
* No longer ignore exceptions raised by comparisons during key lookup.Raymond Hettinger2005-09-161-48/+44
| | | | Inspired by Armin Rigo's suggestion to do the same with dictionaries.
* patch [ 1118729 ] Error in representation of complex numbers(again)Georg Brandl2005-09-161-6/+3
|
* Fix bug in last checkin (2.231). To match previous behavior, unicodeNeil Schemenauer2005-08-311-0/+5
| | | | | subclasses should be substituted as-is and not have tp_str called on them.
* SF bug #1251300: On UCS-4 builds the "unicode-internal" codec will now complainWalter Dörwald2005-08-301-0/+75
| | | | | about illegal code points. The codec now supports PEP 293 style error handlers. (This is a variant of the Nik Haldimann's patch that detects truncated data)
* Disallow keyword arguments for type constructors that don't use them.Georg Brandl2005-08-264-1/+16
| | | | (fixes bug #1119418)
* * Add a fast equality check path for frozensets where the hash value hasRaymond Hettinger2005-08-241-5/+8
| | | | | already been computed. * Apply a GET_SIZE macro().
* SF bug #1242657: list(obj) can swallow KeyboardInterruptRaymond Hettinger2005-08-212-0/+10
| | | | | | Fix over-aggressive PyErr_Clear(). The same code fragment appears in various guises in list.extend(), map(), filter(), zip(), and internally in PySequence_Tuple().
* Add shortcuts for a|a and a&a.Raymond Hettinger2005-08-171-8/+9
|
* Fix nits.Raymond Hettinger2005-08-171-2/+2
|
* Results of a line-by-line comparison back to dictobject.c.Raymond Hettinger2005-08-171-127/+121
| | | | | | | | | | | | * set_merge() cannot assume that the table doesn't resize during iteration. * convert some unnecessary tests to asserts -- they were necessary in dictobject.c because PyDict_Next() is a public function. The same is not true for set_next(). * re-arrange the order of functions to more closely match the order in dictobject.c. This makes it must easier to compare the two and ought to simplify any issues of maintaining both.
* Numerous fix-ups to C API and docs. Added tests for C API.Raymond Hettinger2005-08-161-9/+120
|
* DECREF --> XDECREFRaymond Hettinger2005-08-161-1/+1
|
* Add a C API for sets and frozensets.Raymond Hettinger2005-08-161-8/+72
|
* More function re-ordering (placing like functions together).Raymond Hettinger2005-08-131-86/+86
|
* * Bring lookkey() and lookkey_string() closer to dict version.Raymond Hettinger2005-08-131-93/+77
| | | | | * Use set_next() for looping in issubset() and frozenset_hash(). * Re-order the presentation of cmp and hash functions.
* Fix a too-aggressive assert (see SF#1257960). Previously, gen_iternextPhillip J. Eby2005-08-131-1/+1
| | | | | | | | | was never called during interpreter shutdown GC, so the f_back!=NULL assertion was correct. Now that generators get close()d during GC, the assertion was being triggered because the generator close() was being called as the top-level frame. However, nothing actually is broken by this; it's just that the condition was unexpected in previous Python versions.
* * Fix SF #1257731. Make __contains__(), remove(), and discard() only doRaymond Hettinger2005-08-121-26/+30
| | | | | | | a frozenset conversion when the initial search attempt fails with a TypeError and the key is some type of set. Add a testcase. * Eliminate a duplicate if-stmt.
* Change the %s format specifier for str objects so that it returns aNeil Schemenauer2005-08-122-17/+33
| | | | | unicode instance if the argument is not an instance of basestring and calling __str__ on the argument returns a unicode instance.
* * Add short-circuit code for in-place operations with self (such asRaymond Hettinger2005-08-111-89/+153
| | | | | | | | | | | | | | | | | | | | | s|=s, s&=s, s-=s, or s^=s). Add related tests. * Improve names for several variables and functions. * Provide alternate table access functions (next, contains, add, and discard) that work with an entry argument instead of just a key. This improves set-vs-set operations because we already have a hash value for each key and can avoid unnecessary calls to PyObject_Hash(). Provides a 5% to 20% speed-up for quick hashing elements like strings and integers. Provides much more substantial improvements for slow hashing elements like tuples or objects defining a custom __hash__() function. * Have difference operations resize() when 1/5 of the elements are dummies. Formerly, it was 1/6. The new ratio triggers less frequently and only in cases that it can resize quicker and with greater benefit. The right answer is probably either 1/4, 1/5, or 1/6. Picked the middle value for an even trade-off between resize time and the space/time costs of dummy entries.
* * Bring in INIT_NONZERO_SET_SLOTS macro from dictionary code.Raymond Hettinger2005-08-071-18/+51
| | | | | | | | * Bring in free list from dictionary code. * Improve several comments. * Differencing can leave many dummy entries. If more than 1/6 are dummies, then resize them away. * Factor-out common code with new macro, PyAnySet_CheckExact.
* * Removed checked_error flag which no longer provides any benefit.Raymond Hettinger2005-08-061-15/+12
| | | | * Have issubset() control its own loop instead of using set_next_internal().
* * set_new() doesn't need to zero the structure a second time after tp_allocRaymond Hettinger2005-08-061-3/+6
| | | | | has already done the job. * Use a macro form of PyErr_Occurred() inside the set_lookkey() function.
* Factor away a redundant clear() function.Raymond Hettinger2005-08-061-13/+6
|
* * Improve a variable name: entry0 --> table.Raymond Hettinger2005-08-051-39/+58
| | | | | | | | | | * Give set_lookkey_string() a fast alternate path when no dummy entries are present. * Have set_swap_bodies() reset the hash field to -1 whenever either of bodies is not a frozenset. Maintains the invariant of regular sets always having -1 in the hash field; otherwise, any mutation would make the hash value invalid. * Use an entry pointer to simplify the code in frozenset_hash().
* * Move copyright notice to top and indicate derivation from sets.py andRaymond Hettinger2005-08-051-22/+17
| | | | | | | dictobject.c. * Have frozenset_hash() use entry->hash instead of re-computing each individual hash with PyObject_Hash(o); * Finalize the dummy entry before a system exit.
* Model set.pop() after dict.popitem().Raymond Hettinger2005-08-021-12/+30
|
* PEP 342 implementation. Per Guido's comments, the generator throw()Phillip J. Eby2005-08-021-5/+234
| | | | | method still needs to support string exceptions, and allow None for the third argument. Documentation updates are needed, too.
* * Improve code for the empty frozenset singleton:Raymond Hettinger2005-08-011-63/+66
| | | | | | | | | | | - Handle both frozenset() and frozenset([]). - Do not use singleton for frozenset subclasses. - Finalize the singleton. - Add test cases. * Factor-out set_update_internal() from set_update(). Simplifies the code for several internal callers. * Factor constant expressions out of loop in set_merge_internal(). * Minor comment touch-ups.
* Fix build on gcc: PySetIter_Type should be static in definitionHye-Shik Chang2005-08-011-1/+1
| | | | part also.
* Improve variable names.Raymond Hettinger2005-07-311-154/+154
|
* Fix frozenset() ref count and a comment typo.Raymond Hettinger2005-07-311-3/+2
|
* Comment on the set_swap_bodies() helper function.Raymond Hettinger2005-07-311-0/+13
|
* Revised the set() and frozenset() implementaion to use its own internalRaymond Hettinger2005-07-311-211/+863
| | | | | data structure instead of using dictionaries. Reduces memory consumption by 1/3 and provides modest speed-ups for most set operations.
* SF bug #1238681: freed pointer is used in longobject.c:long_pow().Tim Peters2005-07-171-5/+8
| | | | | | | | | | In addition, long_pow() skipped a necessary (albeit extremely unlikely to trigger) error check when converting an int modulus to long. Alas, I was unable to write a test case that crashed due to either cause. Bugfix candidate.
* Fix:Michael W. Hudson2005-07-121-8/+13
| | | | | | | [ 1229429 ] missing Py_DECREF in PyObject_CallMethod Add a test in test_enumerate, which is a bit random, but suffices (reversed_new calls PyObject_CallMethod under some circumstances).
* SF bug 1185883: PyObject_Realloc can't safely take over a block currentlyTim Peters2005-07-101-27/+23
| | | | | | | | | | managed by C, because it's possible for the block to be smaller than the new requested size, and at the end of allocated VM. Trying to copy over nbytes bytes to a Python small-object block can segfault then, and there's no portable way to avoid this (we would have to know how many bytes starting at p are addressable, and std C has no means to determine that). Bugfix candidate. Should be backported to 2.4, but I'm out of time.
* Apparently some compiler gives a warning onMichael W. Hudson2005-06-301-1/+1
| | | | | | float y = x; when x is a double. Go figure.
* SF bug #1224347: int/long unification and hex()Raymond Hettinger2005-06-292-13/+7
| | | | Hex longs now print with lowercase letters like their int counterparts.
* Insert missing flag.Raymond Hettinger2005-06-191-1/+1
|
* SF patch #1200018: Restore GC support to set objectsRaymond Hettinger2005-06-181-7/+24
| | | | | Reverts 1.26 and 1.27. And adds cycle testing.
* fix object.__divmod__.__doc__Anthony Baxter2005-06-031-2/+8
| | | | backport candidate
* This is my patch:Michael W. Hudson2005-05-271-239/+509
| | | | | | | | | | | | | | [ 1181301 ] make float packing copy bytes when they can which hasn't been reviewed, despite numerous threats to check it in anyway if noone reviews it. Please read the diff on the checkin list, at least! The basic idea is to examine the bytes of some 'probe values' to see if the current platform is a IEEE 754-ish platform, and if so _PyFloat_{Pack,Unpack}{4,8} just copy bytes around. The rest is hair for testing, and tests.
* Disallow opening files with modes 'aU' or 'wU' as specified by PEPSkip Montanaro2005-05-201-0/+51
| | | | 278. Closes bug 967182.
* Fixed a quite misleading comment: a "not" should not have been there.Armin Rigo2005-05-151-1/+1
|
* SF patch #1200051: Small optimization for PyDict_Merge()Raymond Hettinger2005-05-141-0/+6
| | | | (Contributed by Barry Warsaw and Matt Messier.)
* Make subclasses of int, long, complex, float, and unicode perform typeBrett Cannon2005-04-265-75/+73
| | | | | | | conversion using the proper magic slot (e.g., __int__()). Also move conversion code out of PyNumber_*() functions in the C API into the nb_* function. Applied patch #1109424. Thanks Walter Doewald.