Antoine Pitrou
c9dc4a2a8a
Issue #17810 : Implement PEP 3154, pickle protocol 4.
...
Most of the work is by Alexandre.
2013-11-23 18:59:12 +01:00
Eric Snow
b523f8433a
Implement PEP 451 (ModuleSpec).
2013-11-22 09:05:39 -07:00
Nick Coghlan
c72e4e6dcc
Issue #19619 : Blacklist non-text codecs in method API
...
str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings,
rather than attempting the encoding or decoding operation and
then throwing a TypeError for an unexpected output type.
The latter mechanism remains in place for third party non-text
encodings.
2013-11-22 22:39:36 +10:00
Victor Stinner
8455723cfb
Close #19568 : Fix bytearray_setslice_linear(), fix handling of
...
PyByteArray_Resize() failure: leave the bytearray object in an consistent state.
If growth < 0, handling the memory allocation failure is tricky here because
the bytearray object has already been modified. If lo != 0, the operation is
completed, but a MemoryError is still raised and the memory block is not
shrinked. If lo == 0, the bytearray is restored in its previous state and a
MemoryError is raised.
2013-11-21 12:29:51 +01:00
Victor Stinner
35f2803a24
Close #19578 : Fix list_ass_subscript(), handle list_resize() failure
...
Notify the caller of the failure (MemoryError exception).
2013-11-21 12:16:35 +01:00
Christian Heimes
985ecdcfc2
ssue #19183 : Implement PEP 456 'secure and interchangeable hash algorithm'.
...
Python now uses SipHash24 on all major platforms.
2013-11-20 11:46:18 +01:00
Serhiy Storchaka
dc2fd5101a
Remove dead code committed in issue #12892 .
2013-11-19 15:56:05 +02:00
Nick Coghlan
f1de55fb33
Also chain codec exceptions that allow weakrefs
...
The zlib and hex codecs throw custom exception types with
weakref support if the input type is valid, but the data
fails validation. Make sure the exception chaining in the
codec infrastructure can wrap those as well.
2013-11-19 22:33:10 +10:00
Victor Stinner
f91929b1d8
Issue #19646 : repr(dict) now uses _PyUnicodeWriter API for better performances
2013-11-19 13:07:38 +01:00
Victor Stinner
88a9cd9b57
Issue #19513 : repr(tuple) now uses _PyUnicodeWriter for better performances
2013-11-19 12:59:46 +01:00
Victor Stinner
4a58707a34
Add _PyUnicodeWriter_WriteASCIIString() function
2013-11-19 12:54:53 +01:00
Victor Stinner
4d3f109ad3
Issue #19513 : Disable overallocation of the PyUnicodeWriter before the last write
2013-11-19 12:09:00 +01:00
Serhiy Storchaka
58cf607d13
Issue #12892 : The utf-16* and utf-32* codecs now reject (lone) surrogates.
...
The utf-16* and utf-32* encoders no longer allow surrogate code points
(U+D800-U+DFFF) to be encoded.
The utf-32* decoders no longer decode byte sequences that correspond to
surrogate code points.
The surrogatepass error handler now works with the utf-16* and utf-32* codecs.
Based on patches by Victor Stinner and Kang-Hao (Kenny) Lu.
2013-11-19 11:32:41 +02:00
Victor Stinner
b8fb197aa0
Issue #19513 : Simplify list_repr()
2013-11-18 22:15:44 +01:00
Victor Stinner
5c733473f2
Issue #19513 : repr(list) now uses the PyUnicodeWriter API, it is faster than
...
the PyAccu API
2013-11-18 21:11:57 +01:00
Victor Stinner
6989ba0174
Issue #19581 : Change the overallocation factor of _PyUnicodeWriter on Windows
...
On Windows, a factor of 50% gives best performances.
2013-11-18 21:08:39 +01:00
Larry Hastings
ed4a1c5703
Argument Clinic: rename "self" to "module" for module-level functions.
2013-11-18 09:32:13 -08:00
Ezio Melotti
745d54d2fa
#17806 : Added keyword-argument support for "tabsize" to str/bytes.expandtabs().
2013-11-16 19:10:57 +02:00
Nick Coghlan
4b9b936429
Don't decref exc too soon
2013-11-16 00:34:13 +10:00
Victor Stinner
46ef31953e
Issue #19429 , #19437 : fix error handling in the OSError constructor
2013-11-14 22:31:41 +01:00
Benjamin Peterson
e109ee8205
fix refleaks
2013-11-13 23:49:49 -05:00
Benjamin Peterson
079c998872
adjust style
2013-11-13 23:25:01 -05:00
Christian Heimes
6a3db25c70
Issue #17828 : _PyObject_GetDictPtr() may return NULL instead of a PyObject**
...
CID 1128792: Dereference null return value (NULL_RETURNS)
2013-11-14 01:47:14 +01:00
Christian Heimes
507eabdf11
Issue #17828 : va_start() must be accompanied by va_end()
...
CID 1128793: Missing varargs init or cleanup (VARARGS)
2013-11-14 01:39:35 +01:00
Nick Coghlan
8b097b4ed7
Close #17828 : better handling of codec errors
...
- output type errors now redirect users to the type-neutral
convenience functions in the codecs module
- stateless errors that occur during encoding and decoding
will now be automatically wrapped in exceptions that give
the name of the codec involved
2013-11-13 23:49:21 +10:00
Victor Stinner
59799a8399
Don't use deprecated function PyUnicode_GET_SIZE()
...
Replace it with PyUnicode_GET_LENGTH() or PyUnicode_AsUnicodeAndSize()
2013-11-13 14:17:30 +01:00
Victor Stinner
3f36a5736b
Issue #19515 : Remove identifiers duplicated in the same file.
...
Patch written by Andrei Dorian Duma.
2013-11-12 21:39:02 +01:00
Victor Stinner
66b3270975
_Py_normalize_encoding(): explain how the value 6 was computed
2013-11-07 23:12:23 +01:00
Victor Stinner
bd303c165b
Issue #19512 , #19515 : remove shared identifiers, move identifiers where they
...
are used.
Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.
2013-11-07 23:07:29 +01:00
Victor Stinner
07e9e380f9
frameobject.c: Use an identifer instead of creating explicitly an interned
...
string for "__builtins__" literal string
2013-11-07 22:22:39 +01:00
Victor Stinner
df23e30bea
Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"
...
if the input string is NULL
2013-11-07 13:33:36 +01:00
Martin v. Löwis
e75fc14813
Issue #19514 : Deduplicate some _Py_IDENTIFIER declarations.
...
Patch by Andrei Dorian Duma.
2013-11-07 18:46:53 +01:00
Ezio Melotti
a5b9599538
#17080 : improve error message of float/complex when the wrong type is passed.
2013-11-07 19:18:34 +02:00
Victor Stinner
53e9ec48e5
Issue #19512 : Use the new _PyId_builtins identifier
2013-11-07 00:43:05 +01:00
Victor Stinner
ad14ccd047
Issue #19512 : add _PyUnicode_CompareWithId() function
...
_PyUnicode_CompareWithId() is faster than PyUnicode_CompareWithASCIIString()
when both strings are equal and interned.
Add also _PyId_builtins identifier for "builtins" common string.
2013-11-07 00:46:04 +01:00
Victor Stinner
3688aa9a04
Issue #19512 : type_abstractmethods() and type_set_abstractmethods() now use an
...
identifier for the "__abstractmethods__" string
2013-11-06 18:59:18 +01:00
Victor Stinner
5fd2e5ae8a
Issue #19512 : Add a new _PyDict_DelItemId() function, similar to
...
PyDict_DelItemString() but using an identifier for the key
2013-11-06 18:58:22 +01:00
Victor Stinner
7a07e451a4
Issue #19512 : Py_ReprEnter() and Py_ReprLeave() now use an identifier for the
...
"Py_Repr" dictionary key
2013-11-06 18:57:29 +01:00
Victor Stinner
21ea21ef6d
Issue #19424 : PyUnicode_CompareWithASCIIString() normalizes memcmp() result
...
to -1, 0, 1
2013-11-04 11:28:26 +01:00
Victor Stinner
f0c7b2af05
Issue #16286 : remove duplicated identity check from unicode_compare()
...
Move the test to PyUnicode_Compare()
2013-11-04 11:27:14 +01:00
Victor Stinner
fd9e44db37
Issue #16286 : optimize PyUnicode_RichCompare() for identical strings (same
...
pointer) for any operator, not only Py_EQ and Py_NE.
Code of bytes_richcompare() and PyUnicode_RichCompare() is now closer.
2013-11-04 11:23:05 +01:00
Victor Stinner
c8bc5377ac
Issue #16286 : write a new subfunction bytes_compare_eq()
...
* cleanup bytes_richcompare()
* PyUnicode_RichCompare(): replace a test with a XOR
2013-11-04 11:08:10 +01:00
Victor Stinner
e1b1592fd4
Issue #19424 : Fix a compiler warning on comparing signed/unsigned size_t
...
Patch written by Zachary Ware.
2013-11-03 13:53:12 +01:00
Victor Stinner
a6b9b071a3
Issue #19424 : Fix a compiler warning
...
memcmp() just takes raw pointers
2013-10-30 18:27:13 +01:00
Victor Stinner
602f7cf0b9
Issue #19424 : Optimize PyUnicode_CompareWithASCIIString()
...
Use fast memcmp() instead of a loop using the slow PyUnicode_READ() macro.
strlen() is still necessary to check Unicode string containing null bytes.
2013-10-29 23:31:50 +01:00
Antoine Pitrou
84745ab464
Issue #17936 : Fix O(n**2) behaviour when adding or removing many subclasses of a given type.
2013-10-29 21:31:25 +01:00
Victor Stinner
68b674c9d4
Issue #19437 : Fix _PyUnicode_New() (constructor of legacy string), set all
...
attributes before checking for error. The destructor expects all attributes to
be set. It is now safe to call Py_DECREF(unicode) in the constructor.
2013-10-29 19:31:43 +01:00
Victor Stinner
0b0c867178
Issue #19437 : Fix PyObject_CallFunction(), handle Py_VaBuildValue() and
...
PyTuple_New() failure
2013-10-29 19:29:52 +01:00
Victor Stinner
fa3ba4c3bc
Issue #18609 : Add a fast-path for "iso8859-1" encoding
...
On AIX, the locale encoding may be "iso8859-1", which was not a known syntax of
the legacy ISO 8859-1 encoding.
Using a C codec instead of a Python codec is faster but also avoids tricky
issues during Python startup or complex code.
2013-10-29 11:34:05 +01:00
Victor Stinner
bebba5059c
fix indent
2013-10-29 10:56:34 +01:00
Victor Stinner
cc64eb5b9f
Issue #18408 : Fix bytearrayiter.partition()/rpartition(), handle
...
PyByteArray_FromStringAndSize() failure (ex: on memory allocation failure)
2013-10-29 03:15:37 +01:00
Victor Stinner
986e224d5a
Issue #18408 : Fix error handling in PyBytes_FromObject()
...
_PyBytes_Resize(&new) sets new to NULL on error, don't call Py_DECREF() with NULL.
2013-10-29 03:14:22 +01:00
Victor Stinner
a5afb58986
Issue #18408 : Fix PyUnicode_AsUTF8AndSize(), raise MemoryError exception on
...
memory allocation failure
2013-10-29 01:28:23 +01:00
Victor Stinner
41bb43a71e
Issue #18408 : Add a new PyFrame_FastToLocalsWithError() function to handle
...
exceptions when merging fast locals into f_locals of a frame.
PyEval_GetLocals() now raises an exception and return NULL on failure.
2013-10-29 01:19:37 +01:00
Serhiy Storchaka
f740d467bf
Issue #19369 : Optimized the usage of __length_hint__().
2013-10-24 23:19:51 +03:00
Serhiy Storchaka
c679227e31
Issue #1772673 : The type of `char*` arguments now changed to `const char*`.
2013-10-19 21:03:34 +03:00
Serhiy Storchaka
55e092f545
Issue #19279 : UTF-7 decoder no more produces illegal strings.
2013-10-19 20:39:28 +03:00
Serhiy Storchaka
35804e4c63
Issue #19279 : UTF-7 decoder no more produces illegal strings.
2013-10-19 20:38:19 +03:00
Larry Hastings
3182680210
Issue #16612 : Add "Argument Clinic", a compile-time preprocessor
...
for C files to generate argument parsing code. (See PEP 436.)
2013-10-19 00:09:25 -07:00
Benjamin Peterson
94d08d908b
upgrade unicode db to 6.3.0 ( closes #19221 )
2013-10-10 17:24:45 -04:00
Victor Stinner
6cf185dc06
Issue #18874 : _PyObject_Malloc/Realloc/Free() now falls back on
...
_PyMem_RawMalloc/Realloc/Free, instead of _PyMem_Malloc/Realloc/Free. So it
becomes possible to use the fast pymalloc allocator for the PYMEM_DOMAIN_MEM
domain (PyMem_Malloc/Realloc/Free functions).
2013-10-10 15:58:42 +02:00
Victor Stinner
7c74de4d00
Issue #18874 : PyCode_New() now ensures that the filename is a ready Unicode
...
string. This change does nothing is most cases, but it is useful on Windows in
some cases.
2013-10-10 15:55:14 +02:00
Tim Peters
9259c21a63
Issue #19171 : speed some cases of 3-argument long pow().
...
Reduce the base by the modulus when the base is larger than
the modulus. This can unboundedly speed the "startup costs"
of doing modular exponentiation, particularly in cases where
the base is much larger than the modulus. Original patch
by Armin Rigo, inspired by https://github.com/pyca/ed25519 .
Merged from 3.3.
2013-10-05 16:55:38 -05:00
Tim Peters
81a93159d7
Issue #19171 : speed some cases of 3-argument long pow().
...
Reduce the base by the modulus when the base is larger than
the modulus. This can unboundedly speed the "startup costs"
of doing modular exponentiation, particularly in cases where
the base is much larger than the modulus. Original patch
by Armin Rigo, inspired by https://github.com/pyca/ed25519 .
2013-10-05 16:53:52 -05:00
Ezio Melotti
e898153c0f
#19069 : merge with 3.3.
2013-10-06 00:46:58 +03:00
Ezio Melotti
7760b4eb4b
#19069 : use imperative mood in float object docstrings. Patch by Marco Buttu.
2013-10-06 00:45:11 +03:00
Ezio Melotti
c1ae254717
#19068 : merge with 3.3.
2013-10-06 00:39:44 +03:00
Ezio Melotti
488d244e1a
#19068 : use imperative mood in complex object docstrings. Patch by Marco Buttu.
2013-10-06 00:39:18 +03:00
Ezio Melotti
b32a8111c9
#19067 : merge with 3.3.
2013-10-06 00:38:19 +03:00
Ezio Melotti
5792ce151c
#19067 : use imperative mood in range object docstrings. Patch by Marco Buttu.
2013-10-06 00:36:45 +03:00
Antoine Pitrou
5b72075387
Hopefully fix Windows compilation error following 499a96611baa
2013-10-05 21:24:10 +02:00
Antoine Pitrou
5df8a8a1fd
Issue #19087 : Improve bytearray allocation in order to allow cheap popping of data at the front (slice deletion).
2013-10-05 21:12:18 +02:00
Antoine Pitrou
0e61ed8400
Issue #19014 : memoryview.cast() is now allowed on zero-length views.
2013-10-03 19:56:54 +02:00
Antoine Pitrou
60b183407c
Issue #19014 : memoryview.cast() is now allowed on zero-length views.
2013-10-03 19:55:41 +02:00
Nick Coghlan
a0f169cde8
Close #19078 : memoryview now supports reversed
...
Patch by Claudiu Popa
2013-10-02 22:06:54 +10:00
Raymond Hettinger
c13516b0a0
merge
2013-10-01 01:00:59 -07:00
Raymond Hettinger
2ff2190b62
Issue #18594 : Fix the fast path for collections.Counter().
...
The path wasn't being taken due to an over-restrictive type check.
2013-10-01 00:55:43 -07:00
Nick Coghlan
6ba64f454d
Close #18596 : Support address sanity checking in clang/GCC
...
This patch appropriately marks known false alarms in the
small object allocator when address sanity checking is
enabled (patch contributed by Dhiru Kholia).
2013-09-29 00:28:55 +10:00
Georg Brandl
7cba5fd267
Fix minor typo.
2013-09-25 09:04:23 +02:00
Raymond Hettinger
710a67edfc
Note that LINEAR_PROBES can be set to zero.
2013-09-21 20:17:31 -07:00
Raymond Hettinger
4ef0528b97
Minor beautification. Put updates and declarations in a more logical order.
2013-09-21 15:39:49 -07:00
Raymond Hettinger
0ce1953bf7
When LINEAR_PROBES=0, let the compiler remove the dead code on its own.
2013-09-21 14:07:18 -07:00
Raymond Hettinger
c70a2b7bb9
Make the linear probe sequence clearer.
2013-09-21 14:02:55 -07:00
Tim Peters
df099f5df6
Update internal comments to say _something_ about the "API ID".
...
Best I can tell, the possible values for this aren't documented anywhere.
2013-09-19 21:06:37 -05:00
Raymond Hettinger
8408dc581e
Issue 18771: Make it possible to set the number linear probes at compile-time.
2013-09-15 14:57:15 -07:00
Raymond Hettinger
742d8716ff
Put the defines in the logical section and fix indentation.
2013-09-08 00:25:57 -07:00
Raymond Hettinger
583cd03fd1
Minor code beautification.
2013-09-07 22:06:35 -07:00
Raymond Hettinger
4ea9080da9
Improve code clarity by removing two unattractive macros.
2013-09-07 21:01:29 -07:00
Raymond Hettinger
8f8839e10a
Remove the freelist scheme for setobjects.
...
The setobject freelist was consuming memory but not providing much value.
Even when a freelisted setobject was available, most of the setobject
fields still needed to be initialized and the small table still required
a memset(). This meant that the custom freelisting scheme for sets was
providing almost no incremental benefit over the default Python freelist
scheme used by _PyObject_Malloc() in Objects/obmalloc.c.
2013-09-07 20:26:50 -07:00
Raymond Hettinger
04fd9dd52b
Small rearrangement to bring together the three functions for probing the hash table.
2013-09-07 17:41:01 -07:00
Raymond Hettinger
ae7b00e2d3
Move the overview comment to the top of the file.
2013-09-07 15:05:00 -07:00
Tim Peters
b2372959ab
Nerge 3.3 into default.
...
Issue #18942 : sys._debugmallocstats() output was damaged on Windows.
_PyDebugAllocatorStats() called PyOS_snprintf() with a %zd format
code, but MS doesn't support that code. Interpolated
PY_FORMAT_SIZE_T in place of the "z".
2013-09-05 23:04:26 -05:00
Tim Peters
eaa3bcc370
Issue #18942 : sys._debugmallocstats() output was damaged on Windows.
...
_PyDebugAllocatorStats() called PyOS_snprintf() with a %zd format
code, but MS doesn't support that code. Interpolated
PY_FORMAT_SIZE_T in place of the "z".
2013-09-05 22:57:04 -05:00
Raymond Hettinger
c56e0e3980
Minor touchups.
2013-09-02 16:32:27 -07:00
Raymond Hettinger
69492dab07
Factor-out the common code for setting a KeyError.
2013-09-02 15:59:26 -07:00
Raymond Hettinger
a35adf5b09
Instead of XORed indicies, switch to a hybrid of linear probing and open addressing.
...
Modern processors tend to make consecutive memory accesses cheaper than
random probes into memory.
Small sets can fit into L1 cache, so they get less benefit. But they do
come out ahead because the consecutive probes don't probe the same key
more than once and because the randomization step occurs less frequently
(or not at all).
For the open addressing step, putting the perturb shift before the index
calculation gets the upper bits into play sooner.
2013-09-02 03:23:21 -07:00
Raymond Hettinger
6c3c1ccd1b
Update copyright.
2013-08-31 21:34:24 -07:00
Raymond Hettinger
95c0d67581
Further reduce the cost of hash collisions by inspecting an additional nearby entry.
2013-08-31 21:27:08 -07:00
Ethan Furman
fb13721b1b
Close #18780 : %-formatting now prints value for int subclasses with %d, %i, and %u codes.
2013-08-31 10:18:55 -07:00
Raymond Hettinger
afe890923f
Tighten-up the lookkey() logic and beautify the code a bit.
...
Use less code by moving many of the steps from the initial
lookup into the main search loop.
Beautify the code but keep the overall logic unchanged.
2013-08-28 20:59:31 -07:00
Serhiy Storchaka
46e1ce214b
Issue #18783 : Removed existing mentions of Python long type in docstrings,
...
error messages and comments.
2013-08-27 20:17:03 +03:00
Serhiy Storchaka
9594942716
Issue #18783 : Removed existing mentions of Python long type in docstrings,
...
error messages and comments.
2013-08-27 19:40:23 +03:00
Victor Stinner
33824f6fd7
Restore changeset 5bd9db528aed (issue #18408 )
...
"Issue #18408 : PyObject_Str(), PyObject_Repr() and type_call() now fail with an
assertion error if they are called with an exception set (PyErr_Occurred()).
As PyEval_EvalFrameEx(), they may clear the current exception and so the caller
looses its exception."
2013-08-26 14:05:19 +02:00
Victor Stinner
e51321020c
Issue #18408 : _PyObject_Dump() now saves/restores the current exception
...
So it can be called even if an exception was raised
2013-08-26 13:49:06 +02:00
Tim Peters
1544fc5312
Various clarifications based on feedback & questions over the years.
2013-08-24 15:31:07 -05:00
Tim Peters
ec8147ba55
Various clarifications based on feedback & questions over the years.
...
(grafted from 23181bf411a16287a0a54e910fc0f9ecd2764bf0)
2013-08-24 15:15:19 -05:00
Antoine Pitrou
9d95254bb7
Issue #18772 : fix the gdb plugin after the set implementation changes
2013-08-24 21:07:07 +02:00
Antoine Pitrou
91541931f5
Back out 5bd9db528aed (issue #18408 ). It caused unsolved buildbot failures.
2013-08-23 23:18:20 +02:00
Raymond Hettinger
bfc1e1a9cd
Add the same dummy type that is used in dictionaries.
2013-08-23 03:22:15 -05:00
Tim Peters
a1db94554b
Add line explaining the "%sort" test.
2013-08-22 18:42:02 -05:00
Tim Peters
01e75a699d
Add line explaining the "%sort" test.
...
(grafted from 1ea833ecaf5a9d43a886e9e73b4e2551d0d5b548)
2013-08-22 18:32:53 -05:00
Raymond Hettinger
fcf3b500ba
Issue 18797: Remove unneeded refcount adjustments for dummy objects.
...
It suffices to keep just one reference when the object is created.
2013-08-22 08:20:31 -07:00
Raymond Hettinger
5bb1b1dd6f
Hoist the global dummy lookup out of the inner loop for set_merge().
2013-08-21 01:34:18 -07:00
Raymond Hettinger
929cbac307
Remove a redundant hash table probe (this was artifact from an earlier draft of the patch).
2013-08-20 23:03:28 -07:00
Raymond Hettinger
ae9e616a00
Issue 18772: Restore set dummy object back to unicode and restore the identity checks in lookkey().
...
The Gdb prettyprint plugin depended on the dummy object being displayable.
Other solutions besides a unicode object are possible. For now, get it
back up and running.
The identity checks in lookkey() need to be there to prevent the dummy
object from leaking through Py_RichCompareBool() into user code in the
rare circumstance where the dummy's hash value exactly matches the hash
value of the actual key being looked up.
2013-08-20 22:28:24 -07:00
Raymond Hettinger
3c0a4f5def
Issue18771: Reduce the cost of hash collisions for set objects.
2013-08-19 07:36:04 -07:00
Raymond Hettinger
07351a0449
Remove the else-clause because the conditions are no longer mutually exclusive.
2013-08-17 02:39:46 -07:00
Raymond Hettinger
237b34b074
Use a known unique object for the dummy entry.
...
This lets us run PyObject_RichCompareBool() without
first needing to check whether the entry is a dummy.
2013-08-17 02:31:53 -07:00
Serhiy Storchaka
8fa8ee3970
Issue #18701 : Remove support of old CPython versions (<3.0) from C code.
2013-08-17 00:48:02 +03:00
Raymond Hettinger
8ad3919577
Hoist the global "dummy" lookup outside of the reinsertion loop.
2013-08-15 02:18:55 -07:00
Raymond Hettinger
d06eeb4a24
merge
2013-08-13 18:20:55 -07:00
Raymond Hettinger
b1b915c796
Issue 18719: Remove a false optimization
...
Remove an unused early-out test from the critical path for
dict and set lookups.
When the strings already have matching lengths, kinds, and hashes,
there is no additional information gained by checking the first
characters (the probability of a mismatch is already known to
be less than 1 in 2**64).
2013-08-13 18:16:34 -07:00
Antoine Pitrou
9ed5f27266
Issue #18722 : Remove uses of the "register" keyword in C code.
2013-08-13 20:18:52 +02:00
Raymond Hettinger
c629d4c9a2
Replace outdated optimization with clearer code that compiles better.
...
Letting the compiler decide how to optimize the multiply by five
gives it the freedom to make better choices for the best technique
for a given target machine.
For example, GCC on x86_64 produces a little bit better code:
Old-way (3 steps with a data dependency between each step):
shrq $5, %r13
leaq 1(%rbx,%r13), %rax
leaq (%rax,%rbx,4), %rbx
New-way (3 steps with no dependency between the first two steps
which can be run in parallel):
leaq (%rbx,%rbx,4), %rax # i*5
shrq $5, %r13 # perturb >>= PERTURB_SHIFT
leaq 1(%r13,%rax), %rbx # 1 + perturb + i*5
2013-08-05 22:24:50 -07:00
Antoine Pitrou
58720d6145
Issue #17934 : Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles.
2013-08-05 23:26:40 +02:00
Raymond Hettinger
c86d7e989c
Silence compiler warning for an unused declaration
2013-08-04 12:00:36 -07:00
Raymond Hettinger
e56666d17f
Silence compiler warning about an uninitialized variable
2013-08-04 11:51:03 -07:00
Raymond Hettinger
5ed1b38a7d
merge
2013-08-04 11:51:35 -07:00
Serhiy Storchaka
579ddc2fd4
Issue #16741 : Fix an error reporting in int().
2013-08-03 21:14:05 +03:00
Serhiy Storchaka
f6d0aeeadc
Issue #16741 : Fix an error reporting in int().
2013-08-03 20:55:06 +03:00
Mark Dickinson
02515f7a3a
Minor consistency fixes for some longobject.c exception messages:
...
- replace 'long int' / 'long' by 'int'
- fix capitalization of "Python" in PyLong_AsUnsignedLong
- "is too large" -> "too large", for consistency with other messages.
2013-08-03 12:08:22 +01:00
Antoine Pitrou
dcedaf6e53
Issue #18214 : Improve finalization of Python modules to avoid setting their globals to None, in most cases.
2013-07-31 23:14:08 +02:00
Antoine Pitrou
796564c27b
Issue #18112 : PEP 442 implementation (safe object finalization).
2013-07-30 19:59:21 +02:00
Victor Stinner
5b3b1006bb
Issue #18520 : Fix _PyDict_GetItemId(), suppress _PyUnicode_FromId() error
...
As PyDict_GetItem(), _PyDict_GetItemId() suppresses all errors that may occur,
for historical reasons.
2013-07-22 23:50:57 +02:00
Victor Stinner
34f96b8dd3
Issue #18520 : Fix PyFunction_NewWithQualName() error handling
2013-07-22 23:04:55 +02:00
Victor Stinner
4d1f5d6eee
Reindent PyFunction_NewWithQualName()
2013-07-22 23:02:05 +02:00
Victor Stinner
1c8f059019
Issue #18520 : Add a new PyStructSequence_InitType2() function, same than
...
PyStructSequence_InitType() except that it has a return value (0 on success,
-1 on error).
* PyStructSequence_InitType2() now raises MemoryError on memory allocation failure
* Fix also some calls to PyDict_SetItemString(): handle error
2013-07-22 22:24:54 +02:00
Christian Heimes
6895947570
Propagate error when PyByteArray_Resize() fails in bytearray_translate()
...
CID 715334
2013-07-21 02:04:44 +02:00
Christian Heimes
c731bbe665
Propagate error when PyByteArray_Resize() fails in bytearray_translate()
...
CID 715334
2013-07-21 02:04:35 +02:00
Christian Heimes
b578735dff
Check return value of PyType_Ready(&EncodingMapType)
...
CID 486654
2013-07-20 14:57:28 +02:00
Christian Heimes
26532f7519
Check return value of PyType_Ready(&EncodingMapType)
...
CID 486654
2013-07-20 14:57:16 +02:00
Christian Heimes
de4d183955
Issue #18327 : Fix argument order in call to compatible_for_assignment(oldto, newto, attr).
...
The fix only affects the error message of __class__ assignment. CID 983564
2013-07-20 14:19:46 +02:00
Victor Stinner
2c40f640d9
Issue #18408 : Fix list_ass_slice(), handle list_resize() failure
...
I tested the patch manually by injecting a fault using gdb: list items are
correctly restored on failure.
2013-07-19 23:06:21 +02:00
Victor Stinner
8e47832737
Issue #18408 : PyObject_Str(), PyObject_Repr() and type_call() now fail with an
...
assertion error if they are called with an exception set (PyErr_Occurred()).
As PyEval_EvalFrameEx(), they may clear the current exception and so the caller
looses its exception.
2013-07-18 01:49:30 +02:00
Victor Stinner
f97dfd7b59
Issue #18408 : Fix dict_repr(), don't call PyObject_Repr() with an exception set
...
PyObject_Repr() can removes the current exception. For example, module_repr()
calls PyErr_Clear() if calling loader.module_repr(mod) failed.
2013-07-18 01:00:45 +02:00
Victor Stinner
08a80b11ad
longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called on
...
small integers (0 or 1 digit)
2013-07-17 22:33:42 +02:00
Victor Stinner
8aed6f1c7d
Issue #18408 : Rewrite NEGATE() macro in longobject.c to handle PyLong_FromLong() failure
2013-07-17 22:31:17 +02:00
Victor Stinner
5967bf4928
Issue #18408 : Fix PyType_Ready(), handle _PyDict_SetItemId() failure
2013-07-17 22:01:37 +02:00
Victor Stinner
e901d1fbdf
Issue #18408 : Fix Py_ReprEnter(), handle PyList_Append() failure
2013-07-17 21:58:41 +02:00
Victor Stinner
095d99ffff
Issue #18408 : Fix listpop(), handle list_ass_slice() failure
2013-07-17 21:58:01 +02:00