Commit Graph

5248 Commits

Author SHA1 Message Date
Raymond Hettinger 70559b5c20 Issue #24681: Move the store of so->table to the code block where it is used. 2015-07-23 07:42:23 -04:00
Serhiy Storchaka c8fe04484e Issue #23573: Restored optimization of bytes.rfind() and bytearray.rfind()
for single-byte argument on Linux.
2015-07-20 22:58:29 +03:00
Serhiy Storchaka d92d4efe3d Issue #23573: Restored optimization of bytes.rfind() and bytearray.rfind()
for single-byte argument on Linux.
2015-07-20 22:58:02 +03:00
Raymond Hettinger ff9e18a863 Issue #24583: Consolidate previous set object updates into a single function
with a single entry point, named exit points at the bottom, more self-evident
refcount adjustments, and a comment describing why the pre-increment was
necessary at all.
2015-07-20 07:34:05 -04:00
Raymond Hettinger 482c05cbb5 Issue #24583: Fix refcount leak. 2015-07-20 01:23:32 -04:00
Raymond Hettinger 061091a7c5 Issue #24583: Fix crash when set is mutated while being updated. 2015-07-15 23:54:02 -07:00
Raymond Hettinger d702044bcd merge 2015-07-15 23:52:29 -07:00
Raymond Hettinger a3626bc5bd Issue #24583: Fix crash when set is mutated while being updated. 2015-07-15 23:50:14 -07:00
Raymond Hettinger 5d2385ff6f Neaten-up a little bit. 2015-07-08 11:52:27 -07:00
Raymond Hettinger 9632a7d735 Issue 24581: Revert c9782a9ac031 pending a stronger test for mutation during iteration. 2015-07-07 15:29:24 -07:00
Raymond Hettinger 11ce8e6c37 Minor bit of factoring-out common code. 2015-07-06 19:08:49 -07:00
Raymond Hettinger 3dbc11cadd Tighten-up code in the set iterator to use an entry pointer rather than indexing. 2015-07-06 19:03:01 -07:00
Raymond Hettinger ef6bd7d963 Tighten-up code in set_next() to use an entry pointer rather than indexing. 2015-07-06 08:43:37 -07:00
Raymond Hettinger b48d6a63ff Bring related functions add/contains/discard together in the code. 2015-07-05 16:27:44 -07:00
Raymond Hettinger 73799b181e Change add/contains/discard calls to pass the key and hash instead of an entry struct. 2015-07-05 16:06:10 -07:00
Raymond Hettinger dc28d5a198 Clean-up call patterns for add/contains/discard to better match the caller's needs. 2015-07-05 10:03:20 -07:00
Benjamin Peterson 191a8f0a34 merge heads 2015-07-04 22:53:45 -05:00
Benjamin Peterson d34c246baf merge 3.5 (#24407) 2015-07-04 19:59:50 -05:00
Benjamin Peterson e54d5321cc merge 3.4 (#24407) 2015-07-04 19:59:24 -05:00
Benjamin Peterson 2a48a6eb33 merge 3.3 (#24407) 2015-07-04 19:58:11 -05:00
Benjamin Peterson a82f77fb00 protect against mutation of the dict during insertion (closes #24407) 2015-07-04 19:55:16 -05:00
Raymond Hettinger ac2ef65c32 Make the unicode equality test an external function rather than in-lining it.
The real benefit of the unicode specialized function comes from
bypassing the overhead of PyObject_RichCompareBool() and not
from being in-lined (especially since there was almost no shared
data between the caller and callee).  Also, the in-lining was
having a negative effect on code generation for the callee.
2015-07-04 16:04:44 -07:00
Raymond Hettinger e186c7674c Make sure the dummy percentage calculation won't overflow. 2015-07-04 11:28:35 -07:00
Raymond Hettinger c2480dc0c4 Minor cleanup. 2015-07-04 08:46:31 -07:00
Raymond Hettinger b322326f48 Minor nit: Make the style of checking error return values more consistent. 2015-07-03 23:37:16 -07:00
Raymond Hettinger 4897300276 Minor factoring: move redundant resize scaling logic into the resize function. 2015-07-03 20:00:03 -07:00
Raymond Hettinger 3c1f52e829 Call set_lookkey() directly to avoid unnecessary memory spills and reloads. 2015-07-03 18:31:09 -07:00
Raymond Hettinger 15f0869609 Move insertion resize logic into set_insert_key().
Simplifies the code a little bit and does the resize check
only when a new key is added (giving a small speed up in
the case where the key already exists).

Fixes possible bug in set_merge() where the set_insert_key()
call relies on a big resize at the start to make enough room
for the keys but is vulnerable to a comparision callback that
could cause the table to shrink in the middle of the merge.

Also, changed the resize threshold from two-thirds of the
mask+1 to just two-thirds.  The plus one offset gave no
real benefit (afterall, the two-thirds mark is just a
heuristic and isn't a precise cut-off).
2015-07-03 17:21:17 -07:00
Yury Selivanov bb215e2300 Merge 3.5 (Issue #19235) 2015-07-03 01:10:11 -04:00
Yury Selivanov f488fb422a Issue #19235: Add new RecursionError exception. Patch by Georg Brandl. 2015-07-03 01:04:23 -04:00
Yury Selivanov d6d0b5b1fa Merge 3.5 (Issue #24450) 2015-07-03 00:24:14 -04:00
Yury Selivanov e13f8f3cab Issue #24450: Add gi_yieldfrom to generators; cr_await to coroutines.
Patch by Benno Leslie and Yury Selivanov.
2015-07-03 00:23:30 -04:00
Serhiy Storchaka 81da944d61 Issue #24467: Fixed possible buffer over-read in bytearray. The bytearray
object now always allocates place for trailing null byte and it's buffer now
is always null-terminated.
2015-06-29 21:18:55 +03:00
Serhiy Storchaka bc9e75ed02 Issue #24467: Fixed possible buffer over-read in bytearray. The bytearray
object now always allocates place for trailing null byte and it's buffer now
is always null-terminated.
2015-06-29 21:18:01 +03:00
Serhiy Storchaka 7b6e3b91f5 Issue #24467: Fixed possible buffer over-read in bytearray. The bytearray
object now always allocates place for trailing null byte and it's buffer now
is always null-terminated.
2015-06-29 21:14:06 +03:00
Raymond Hettinger 2eff9e9441 Minor refactoring. Move reference count logic into function that adds entry. 2015-06-27 22:03:35 -07:00
Benjamin Peterson b5048d3938 merge 3.5 2015-06-27 15:46:31 -05:00
Benjamin Peterson 4801383c29 upgrade to Unicode 8.0.0 2015-06-27 15:45:56 -05:00
Raymond Hettinger 91672617d5 Minor tweeak to tighten the inner-loop. 2015-06-26 02:50:21 -07:00
Yury Selivanov b257b7993c Merge 3.5 (issue #24439) 2015-06-24 11:04:39 -04:00
Yury Selivanov 66f8828bfc Issue #24439: Improve PEP 492 related docs.
Patch by Martin Panter.
2015-06-24 11:04:15 -04:00
Raymond Hettinger 38bb95e49d Minor code cleanup. 2015-06-24 01:22:19 -07:00
Yury Selivanov 6edc2f7549 Issue #24400: Merge 3.5 2015-06-22 12:31:24 -04:00
Yury Selivanov 5376ba9630 Issue #24400: Introduce a distinct type for 'async def' coroutines.
Summary of changes:

1. Coroutines now have a distinct, separate from generators
   type at the C level: PyGen_Type, and a new typedef PyCoroObject.
   PyCoroObject shares the initial segment of struct layout with
   PyGenObject, making it possible to reuse existing generators
   machinery.  The new type is exposed as 'types.CoroutineType'.

   As a consequence of having a new type, CO_GENERATOR flag is
   no longer applied to coroutines.

2. Having a separate type for coroutines made it possible to add
   an __await__ method to the type.  Although it is not used by the
   interpreter (see details on that below), it makes coroutines
   naturally (without using __instancecheck__) conform to
   collections.abc.Coroutine and collections.abc.Awaitable ABCs.

   [The __instancecheck__ is still used for generator-based
   coroutines, as we don't want to add __await__ for generators.]

3. Add new opcode: GET_YIELD_FROM_ITER.  The opcode is needed to
   allow passing native coroutines to the YIELD_FROM opcode.

   Before this change, 'yield from o' expression was compiled to:

      (o)
      GET_ITER
      LOAD_CONST
      YIELD_FROM

   Now, we use GET_YIELD_FROM_ITER instead of GET_ITER.

   The reason for adding a new opcode is that GET_ITER is used
   in some contexts (such as 'for .. in' loops) where passing
   a coroutine object is invalid.

4. Add two new introspection functions to the inspec module:
   getcoroutinestate(c) and getcoroutinelocals(c).

5. inspect.iscoroutine(o) is updated to test if 'o' is a native
   coroutine object.  Before this commit it used abc.Coroutine,
   and it was requested to update inspect.isgenerator(o) to use
   abc.Generator; it was decided, however, that inspect functions
   should really be tailored for checking for native types.

6. sys.set_coroutine_wrapper(w) API is updated to work with only
   native coroutines.  Since types.coroutine decorator supports
   any type of callables now, it would be confusing that it does
   not work for all types of coroutines.

7. Exceptions logic in generators C implementation was updated
   to raise clearer messages for coroutines:

   Before: TypeError("generator raised StopIteration")
   After: TypeError("coroutine raised StopIteration")
2015-06-22 12:19:30 -04:00
Raymond Hettinger 7e3592dca6 Harmonize the bottom of the outer loop with its entry point
giving a small simplification.  Timings show that hash
pre-check seems only benefit the inner-loop (the linear probes).
2015-06-21 10:47:20 -07:00
Raymond Hettinger 6ee588f14e Restore quick exit (no freeslot check) for common case (found null on first probe). 2015-06-20 21:39:51 -07:00
Serhiy Storchaka ec466a15d9 Fixed indentation of Python examples in C comments. 2015-06-11 00:09:32 +03:00
Serhiy Storchaka 553e156921 Fixed indentation of Python examples in C comments. 2015-06-11 00:07:47 +03:00
Serhiy Storchaka d741a88049 Fixed indentation of Python examples in C comments. 2015-06-11 00:06:39 +03:00
Benjamin Peterson 239e90196e Merge 3.5 2015-06-07 00:00:48 -05:00