summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
Commit message (Collapse)AuthorAgeFilesLines
...
* | Issue #27125: Merge typo fixes from 3.5Martin Panter2016-05-301-1/+1
|\ \ | |/
| * Issue #27125: Remove duplicated words from documentation and commentsMartin Panter2016-05-301-1/+1
| |
* | Issue #26765: Moved common code for the replace() method of bytes and bytearraySerhiy Storchaka2016-05-051-505/+3
| | | | | | | | to a template file.
* | Issue #26765: Moved common code and docstrings for bytes and bytearray methodsSerhiy Storchaka2016-05-041-336/+26
| | | | | | | | to bytes_methods.c.
* | Got rid of redundand "self" parameter declarations.Serhiy Storchaka2016-05-021-26/+20
| | | | | | | | Argument Clinic is now able to infer all needed information.
* | Issue #25349, #26249: Fix memleak in formatfloat()Victor Stinner2016-04-261-0/+1
| |
* | Issue #26766: Fix _PyBytesWriter_Finish()Victor Stinner2016-04-151-1/+6
| | | | | | | | | | | | | | Return a bytearray object when bytearray is requested and when the small buffer is used. Fix also test_bytes: bytearray%args must return a bytearray type.
* | Issue #26764: Fixed SystemError in bytes.__rmod__.Serhiy Storchaka2016-04-151-6/+4
| |
* | Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREFSerhiy Storchaka2016-04-101-1/+1
|\ \ | |/ | | | | in places where Py_DECREF was used.
| * Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREFSerhiy Storchaka2016-04-101-1/+1
| | | | | | | | in places where Py_DECREF was used.
* | Issue #17339: Improved TypeError message in bytes constructor.Serhiy Storchaka2016-04-101-16/+15
| |
* | Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-1/+1
|\ \ | |/
| * Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-1/+1
| |
* | Issue #26494: Fixed crash on iterating exhausting iterators.Serhiy Storchaka2016-03-301-1/+1
|\ \ | |/ | | | | | | | | Affected classes are generic sequence iterators, iterators of str, bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding views and os.scandir() iterator.
| * Issue #26494: Fixed crash on iterating exhausting iterators.Serhiy Storchaka2016-03-301-1/+1
| | | | | | | | | | | | Affected classes are generic sequence iterators, iterators of str, bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding views and os.scandir() iterator.
* | Optimize bytes.replace(b'', b'.')Victor Stinner2016-03-211-9/+19
| | | | | | | | | | Issue #26574: Optimize bytes.replace(b'', b'.') and bytearray.replace(b'', b'.'): up to 80% faster. Patch written by Josh Snider.
* | Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-1/+1
| | | | | | | | private functions.
* | Issue #20440: Massive replacing unsafe attribute setting code with specialSerhiy Storchaka2015-12-241-2/+1
|\ \ | |/ | | | | macro Py_SETREF.
| * Issue #20440: Massive replacing unsafe attribute setting code with specialSerhiy Storchaka2015-12-241-2/+1
| | | | | | | | macro Py_SETREF.
* | Issue #25766: Special method __bytes__() now works in str subclasses.Serhiy Storchaka2015-12-201-6/+12
|\ \ | |/
| * Issue #25766: Special method __bytes__() now works in str subclasses.Serhiy Storchaka2015-12-201-6/+12
| |
* | Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-4/+4
|\ \ | |/ | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
| * Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-4/+4
| |\ | | | | | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
| | * Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-4/+4
| | | | | | | | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
* | | Issue #24821: Refactor STRINGLIB(fastsearch_memchr_1char) and split it onSerhiy Storchaka2015-11-141-10/+9
| | | | | | | | | | | | | | | STRINGLIB(find_char) and STRINGLIB(rfind_char) that can be used independedly without special preconditions.
* | | Use _PyBytesWriter in _PyBytes_FromIterator()Victor Stinner2015-10-141-19/+18
| | |
* | | Add _PyBytesWriter_Resize() functionVictor Stinner2015-10-141-18/+30
| | | | | | | | | | | | This function gives a control to the buffer size without using min_size.
* | | Factorize _PyBytes_FromList() and _PyBytes_FromTuple() code using a C macroVictor Stinner2015-10-141-54/+35
| | |
* | | Split PyBytes_FromObject() into subfunctionsVictor Stinner2015-10-141-71/+114
| | |
* | | Modify _PyBytes_DecodeEscapeRecode() to use _PyBytesAPIVictor Stinner2015-10-141-58/+73
| | | | | | | | | | | | | | | | | | | | | * Don't overallocate by 400% when recode is needed: only overallocate on demand using _PyBytesWriter. * Use _PyLong_DigitValue to convert hexadecimal digit to int * Create _PyBytes_DecodeEscapeRecode() subfunction
* | | _PyBytesWriter_Alloc(): only use 10 bytes of the small buffer in debug mode toVictor Stinner2015-10-141-1/+13
| | | | | | | | | | | | enhance code to detect buffer under- and overflow.
* | | Optimize bytes.fromhex() and bytearray.fromhex()Victor Stinner2015-10-141-52/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #25401: Optimize bytes.fromhex() and bytearray.fromhex(): they are now between 2x and 3.5x faster. Changes: * Use a fast-path working on a char* string for ASCII string * Use a slow-path for non-ASCII string * Replace slow hex_digit_to_int() function with a O(1) lookup in _PyLong_DigitValue precomputed table * Use _PyBytesWriter API to handle the buffer * Add unit tests to check the error position in error messages
* | | Optimize bytearray % argsVictor Stinner2015-10-141-18/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #25399: Don't create temporary bytes objects: modify _PyBytes_Format() to create work directly on bytearray objects. * Rename _PyBytes_Format() to _PyBytes_FormatEx() just in case if something outside CPython uses it * _PyBytes_FormatEx() now uses (char*, Py_ssize_t) for the input string, so bytearray_format() doesn't need tot create a temporary input bytes object * Add use_bytearray parameter to _PyBytes_FormatEx() which is passed to _PyBytesWriter, to create a bytearray buffer instead of a bytes buffer Most formatting operations are now between 2.5 and 5 times faster.
* | | Add use_bytearray attribute to _PyBytesWriterVictor Stinner2015-10-141-28/+65
| | | | | | | | | | | | | | | Issue #25399: Add a new use_bytearray attribute to _PyBytesWriter to use a bytearray buffer, instead of using a bytes object.
* | | Rewrite PyBytes_FromFormatV() using _PyBytesWriter APIVictor Stinner2015-10-131-171/+165
| | | | | | | | | | | | | | | | | | | | | * Add much more unit tests on PyBytes_FromFormatV() * Remove the first loop to compute the length of the output string * Use _PyBytesWriter to handle the bytes buffer, use overallocation * Cleanup the code to make simpler and easier to review
* | | Fix compilation error in _PyBytesWriter_WriteBytes() on WindowsVictor Stinner2015-10-121-1/+3
| | |
* | | Writer APIs: use empty string singletonsVictor Stinner2015-10-121-9/+14
| | | | | | | | | | | | | | | Modify _PyBytesWriter_Finish() and _PyUnicodeWriter_Finish() to return the empty bytes/Unicode string if the string is empty.
* | | Relax _PyBytesWriter APIVictor Stinner2015-10-121-8/+7
| | | | | | | | | | | | | | | | | | | | | Don't require _PyBytesWriter pointer to be a "char *". Same change for _PyBytesWriter_WriteBytes() parameter. For example, binascii uses "unsigned char*".
* | | Issue #25349: Add fast path for b'%c' % intVictor Stinner2015-10-091-10/+15
| | | | | | | | | | | | Optimize also %% formater.
* | | Issue #25349: Optimize bytes % intVictor Stinner2015-10-091-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | Optimize bytes.__mod__(args) for integere formats: %d (%i, %u), %o, %x and %X. _PyBytesWriter is now used to format directly the integer into the writer buffer, instead of using a temporary bytes object. Formatting is between 30% and 50% faster on a microbenchmark.
* | | Add _PyBytesWriter_WriteBytes() to factorize the codeVictor Stinner2015-10-091-0/+14
| | |
* | | _PyBytesWriter: simplify code to avoid "prealloc" parametersVictor Stinner2015-10-091-9/+7
| | | | | | | | | | | | | | | 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 compilation errorVictor Stinner2015-10-091-1/+1
| | | | | | | | | | | | Replace "#if Py_DEBUG" with "#ifdef Py_DEBUG".
* | | Issue #25318: Move _PyBytesWriter to bytesobject.cVictor Stinner2015-10-081-0/+193
|/ / | | | | | | Declare also the private API in bytesobject.h.
* | Issue #23573: Restored optimization of bytes.rfind() and bytearray.rfind()Serhiy Storchaka2015-07-201-3/+7
| | | | | | | | for single-byte argument on Linux.
* | Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),Serhiy Storchaka2015-05-301-11/+22
|\ \ | |/ | | | | | | PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly.
| * Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),Serhiy Storchaka2015-05-301-7/+13
| | | | | | | | | | PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly.