summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* _PyBytesWriter: simplify code to avoid "prealloc" parametersVictor Stinner2015-10-093-47/+47
| | | | | Substract preallocate bytes from min_size before calling _PyBytesWriter_Prepare().
* _PyBytesWriter: rename size attribute to min_sizeVictor Stinner2015-10-091-7/+7
|
* Issue #25349: Optimize bytes % args using the new private _PyBytesWriter APIVictor Stinner2015-10-091-59/+128
| | | | | | | | | | | | | | | | | * Thanks to the _PyBytesWriter API, output smaller than 512 bytes are allocated on the stack and so avoid calling _PyBytes_Resize(). Because of that, change the default buffer size to fmtcnt instead of fmtcnt+100. * Rely on _PyBytesWriter algorithm to overallocate the buffer instead of using a custom code. For example, _PyBytesWriter uses a different overallocation factor (25% or 50%) depending on the platform to get best performances. * Disable overallocation for the last write. * Replace C loops to fill characters with memset() * Add also many comments to _PyBytes_Format() * Remove unused FORMATBUFLEN constant * Avoid the creation of a temporary bytes object when formatting a floating point number (when no custom formatting option is used) * Fix also reference leaks on error handling * Use Py_MEMCPY() to copy bytes between two formatters (%)
* Issue #25318: cleanup code _PyBytesWriterVictor Stinner2015-10-091-17/+17
| | | | | | Rename "stack buffer" to "small buffer". Add also an assertion in _PyBytesWriter_GetPos().
* Issue #25318: Fix backslashreplace()Victor Stinner2015-10-091-1/+1
| | | | Fix code to estimate the needed space.
* Issue #25318: Avoid sprintf() in backslashreplace()Victor Stinner2015-10-091-7/+18
| | | | | | Rewrite backslashreplace() to be closer to PyCodec_BackslashReplaceErrors(). Add also unit tests for non-BMP characters.
* Issue #25318: Fix compilation errorVictor Stinner2015-10-091-1/+1
| | | | Replace "#if Py_DEBUG" with "#ifdef Py_DEBUG".
* Issue #25318: Move _PyBytesWriter to bytesobject.cVictor Stinner2015-10-082-210/+193
| | | | Declare also the private API in bytesobject.h.
* Optimize backslashreplace error handlerVictor Stinner2015-10-082-51/+160
| | | | | | | | | | Issue #25318: Optimize backslashreplace and xmlcharrefreplace error handlers in UTF-8 encoder. Optimize also backslashreplace error handler for ASCII and Latin1 encoders. Use the new _PyBytesWriter API to optimize these error handlers for the encoders. It avoids to create an exception and call the slow implementation of the error handler.
* Issue #25318: Add _PyBytesWriter APIVictor Stinner2015-10-082-132/+268
| | | | | | | | | | | Add a new private API to optimize Unicode encoders. It uses a small buffer allocated on the stack and supports overallocation. Use _PyBytesWriter API for UCS1 (ASCII and Latin1) and UTF-8 encoders. Enable overallocation for the UTF-8 encoder with error handlers. unicode_encode_ucs1(): initialize collend to collstart+1 to not check the current character twice, we already know that it is not ASCII.
* Merge typo fixes from 3.5Martin Panter2015-10-073-3/+3
|\
| * More typos in 3.5 documentation and commentsMartin Panter2015-10-072-2/+2
| |
| * Merge typo fixes from 3.4 into 3.5Martin Panter2015-10-072-2/+2
| |\
| | * Various minor typos in documentation and commentsMartin Panter2015-10-072-2/+2
| | |
* | | merge 3.5 (closes #24806)Benjamin Peterson2015-10-071-6/+6
|\ \ \ | |/ /
| * | merge 3.4 (#24806)Benjamin Peterson2015-10-071-6/+6
| |\ \ | | |/
| | * prevent unacceptable bases from becoming bases through multiple inheritance ↵Benjamin Peterson2015-10-071-6/+6
| | | | | | | | | | | | (#24806)
* | | Issue #25301: Fix compatibility with ISO C90Victor Stinner2015-10-051-1/+5
| | |
* | | Issue #25301: The UTF-8 decoder is now up to 15 times as fast for errorVictor Stinner2015-10-051-9/+39
| | | | | | | | | | | | handlers: ``ignore``, ``replace`` and ``surrogateescape``.
* | | Fix _PyUnicodeWriter_PrepareKind()Victor Stinner2015-10-021-7/+18
| | | | | | | | | | | | | | | | | | Initialize kind to 0 (PyUnicode_WCHAR_KIND) to ensure that _PyUnicodeWriter_PrepareKind() handles correctly read-only buffer: copy the buffer.
* | | Issue #24848: Fixed bugs in UTF-7 decoding of misformed data:Serhiy Storchaka2015-10-021-9/+12
|\ \ \ | |/ / | | | | | | | | | | | | | | | 1. Non-ASCII bytes were accepted after shift sequence. 2. A low surrogate could be emitted in case of error in high surrogate. 3. In some circumstances the '\xfd' character was produced instead of the replacement character '\ufffd' (due to a bug in _PyUnicodeWriter).
| * | Issue #24848: Fixed bugs in UTF-7 decoding of misformed data:Serhiy Storchaka2015-10-021-9/+12
| |\ \ | | |/ | | | | | | | | | | | | | | | 1. Non-ASCII bytes were accepted after shift sequence. 2. A low surrogate could be emitted in case of error in high surrogate. 3. In some circumstances the '\xfd' character was produced instead of the replacement character '\ufffd' (due to a bug in _PyUnicodeWriter).
| | * Issue #24848: Fixed bugs in UTF-7 decoding of misformed data:Serhiy Storchaka2015-10-021-9/+12
| | | | | | | | | | | | | | | 1. Non-ASCII bytes were accepted after shift sequence. 2. A low surrogate could be emitted in case of error in high surrogate.
* | | Issue #24483: C implementation of functools.lru_cache() now calculates key'sSerhiy Storchaka2015-10-021-0/+37
|\ \ \ | |/ / | | | | | | hash only once.
| * | Issue #24483: C implementation of functools.lru_cache() now calculates key'sSerhiy Storchaka2015-10-021-0/+37
| | | | | | | | | | | | hash only once.
* | | Make _PyUnicode_TranslateCharmap() symbol privateVictor Stinner2015-10-011-1/+1
| | | | | | | | | | | | unicodeobject.h exposes PyUnicode_TranslateCharmap() and PyUnicode_Translate().
* | | Issue #25267: The UTF-8 encoder is now up to 75 times as fast for errorVictor Stinner2015-10-012-53/+101
| | | | | | | | | | | | | | | handlers: ``ignore``, ``replace``, ``surrogateescape``, ``surrogatepass``. Patch co-written with Serhiy Storchaka.
* | | (Merge 3.5) Issue #25182: Fix compilation on WindowsVictor Stinner2015-09-301-3/+6
|\ \ \ | |/ /
| * | (Merge 3.4) Issue #25182: Fix compilation on WindowsVictor Stinner2015-09-301-3/+6
| |\ \ | | |/
| | * Issue #25182: Fix compilation on WindowsVictor Stinner2015-09-301-3/+6
| | | | | | | | | | | | Restore also errno value before calling PyErr_SetFromErrno().
* | | Issue #25182: The stdprinter (used as sys.stderr before the io module isSerhiy Storchaka2015-09-301-4/+21
|\ \ \ | |/ / | | | | | | imported at startup) now uses the backslashreplace error handler.
| * | Issue #25182: The stdprinter (used as sys.stderr before the io module isSerhiy Storchaka2015-09-301-4/+21
| |\ \ | | |/ | | | | | | imported at startup) now uses the backslashreplace error handler.
| | * Issue #25182: The stdprinter (used as sys.stderr before the io module isSerhiy Storchaka2015-09-301-6/+22
| | | | | | | | | | | | imported at startup) now uses the backslashreplace error handler.
* | | Optimize ascii/latin1+surrogateescape encodersVictor Stinner2015-09-291-0/+16
| | | | | | | | | | | | | | | | | | | | | Issue #25227: Optimize ASCII and latin1 encoders with the ``surrogateescape`` error handler: the encoders are now up to 3 times as fast. Initial patch written by Serhiy Storchaka.
* | | Issue #25227: Cleanup unicode_encode_ucs1() error handlerVictor Stinner2015-09-241-9/+13
| | | | | | | | | | | | | | | | | | | | | * Change limit type from unsigned int to Py_UCS4, to use the same type than the "ch" variable (an Unicode character). * Reuse ch variable for _Py_ERROR_XMLCHARREFREPLACE * Add some newlines for readability
* | | Issue #24870: revert unwanted changeVictor Stinner2015-09-221-43/+9
| | | | | | | | | | | | Sorry, I pushed the patch on the UTF-8 decoder by mistake :-(
* | | Issue #25207, #14626: Fix my commit.Victor Stinner2015-09-211-9/+43
| | | | | | | | | | | | | | | It doesn't work to use #define XXX defined(YYY)" and then "#ifdef XXX" to check YYY.
* | | _PyUnicodeWriter_PrepareInternal(): make the assertion more strictVictor Stinner2015-09-211-1/+2
| | |
* | | Issue #24870: Add _PyUnicodeWriter_PrepareKind() macroVictor Stinner2015-09-211-9/+29
| | | | | | | | | | | | Add a macro which ensures that the writer has at least the requested kind.
* | | Issue #24870: Reuse the new _Py_error_handler enumVictor Stinner2015-09-211-87/+77
| | | | | | | | | | | | | | | | | | Factorize code with the new get_error_handler() function. Add some empty lines for readability.
* | | Issue #24870: Optimize the ASCII decoder for error handlers: surrogateescape,Victor Stinner2015-09-211-5/+61
| | | | | | | | | | | | | | | | | | | | | | | | ignore and replace. Initial patch written by Naoki Inada. The decoder is now up to 60 times as fast for these error handlers. Add also unit tests for the ASCII decoder.
* | | Merge 3.5Victor Stinner2015-09-191-4/+6
|\ \ \ | |/ /
| * | Issue #24999: In longobject.c, use two shifts instead of ">> 2*PyLong_SHIFT" toVictor Stinner2015-09-191-4/+6
| | | | | | | | | | | | | | | | | | avoid undefined behaviour when LONG_MAX type is smaller than 60 bits. This change should fix a warning with the ICC compiler.
* | | Merge 3.5 (pytime, odict)Victor Stinner2015-09-181-1/+1
|\ \ \ | |/ /
| * | odictobject.c: fix compiler warningVictor Stinner2015-09-181-1/+1
| | | | | | | | | | | | | | | PyObject_Length() returns a P_ssize_t, not an int. Use a Py_ssize_t to avoid overflow.
* | | Issue #15989: Fixed some scarcely probable integer overflows.Serhiy Storchaka2015-09-061-12/+12
| | | | | | | | | | | | It is very unlikely that they can occur in real code for now.
* | | Issue #24912: Prevent __class__ assignment to immutable built-in objects. ↵Guido van Rossum2015-09-051-0/+59
|\ \ \ | |/ / | | | | | | (Merge 3.5 -> 3.6)
| * | Issue #24912: Prevent __class__ assignment to immutable built-in objects. ↵Guido van Rossum2015-09-051-0/+59
| |\ \ | | | | | | | | | | | | (Merge 3.5.0 -> 3.5)
| | * | Issue #24912: Prevent __class__ assignment to immutable built-in objects.Guido van Rossum2015-09-051-0/+59
| | | |
* | | | Merge 3.5 (odict)Victor Stinner2015-09-031-18/+22
|\ \ \ \ | |/ / /