Victor Stinner
d0dba6eee8
unicode_writer: don't force inline when it is not necessary
Keep inline for performance critical functions (functions used in loops)
14 years ago
Benjamin Peterson
b63f49f2b4
if the kind of the string to count is larger than the string to search, shortcut to 0
14 years ago
Victor Stinner
a7b654be30
unicode_writer: add finish() method and assertions to write_str() method
* The write_str() method does nothing if the length is zero.
* Replace "struct unicode_writer_t" with "unicode_writer_t"
14 years ago
Victor Stinner
bf4e266397
Issue #14687 : Remove redundant length attribute of unicode_write_t
The length can be read directly from the buffer
14 years ago
Victor Stinner
7989157e49
Issue #14687 : Cleanup unicode_writer_prepare()
"Inline" PyUnicode_Resize(): call directly resize_compact()
14 years ago
Victor Stinner
f2c76aa6cb
Issue #14687 : str%tuple now uses an optimistic "unicode writer" instead of an
accumulator. Directly write characters into the output (don't use a temporary
list): resize and widen the string on demand.
14 years ago
Victor Stinner
1b487b467b
Issue #14624 , #14687 : Optimize unicode_widen()
Don't convert uninitialized characters. Patch written by Serhiy Storchaka.
14 years ago
Victor Stinner
3a7f7977f1
Remove buggy assertion in PyUnicode_Substring()
Use also directly unicode_empty, instead of PyUnicode_New(0,0).
14 years ago
Victor Stinner
684d5fd420
Fix PyUnicode_Substring() for start >= length and start > end
Remove the fast-path for 1-character string: unicode_fromascii() and
_PyUnicode_FromUCS*() now have their own fast-path for 1-character strings.
14 years ago
Victor Stinner
b6cd014d75
Unicode: optimize creating of 1-character strings
14 years ago
Victor Stinner
bff7c96834
Issue #14687 : Optimize str%tuple for the "%(name)s" syntax
Avoid an useless and expensive call to PyUnicode_READ().
14 years ago
Victor Stinner
e6abb488c9
unicodeobject.c: Add MAX_MAXCHAR() macro to (micro-)optimize the computation
of the second argument of PyUnicode_New().
* Create also align_maxchar() function
* Optimize fix_decimal_and_space_to_ascii(): don't compute the maximum
character when ch <= 127 (it is ASCII)
14 years ago
Victor Stinner
438106b66e
Issue #14687 : Cleanup PyUnicode_Format()
14 years ago
Victor Stinner
b5c3ea3af3
Issue #14687 : Optimize str%args
* formatfloat() uses unicode_fromascii() instead of PyUnicode_DecodeASCII()
to not have to check characters, we know that it is really ASCII
* Use PyUnicode_FromOrdinal() instead of _PyUnicode_FromUCS4() to format
a character: if avoids a call to ucs4lib_find_max_char() to compute
the maximum character (whereas we already know it, it is just the character
itself)
14 years ago
Victor Stinner
b80e46eca4
Issue #14687 : Avoid an useless duplicated string in PyUnicode_Format()
14 years ago
Victor Stinner
aff3cc659b
Issue #14687 : Cleanup PyUnicode_Format()
14 years ago
Victor Stinner
b11d91d969
Fix my previous commit: bool is a long, restore the specical case for bool
14 years ago
Victor Stinner
d0880d57b0
Simplify and optimize formatlong()
* Remove _PyBytes_FormatLong(): inline it into formatlong()
* the input type is always a long, so remove the code for bool
* don't duplicate the string if the length does not change
* Use PyUnicode_DATA() instead of _PyUnicode_AsString()
14 years ago
Victor Stinner
94d558b063
Optimize _PyUnicode_FindMaxChar() find pure ASCII strings
14 years ago
Victor Stinner
8f825060f1
Check newly created consistency using _PyUnicode_CheckConsistency(str, 1)
* In debug mode, fill the string data with invalid characters
* Simplify also reference counting in PyCodec_BackslashReplaceErrors()
and PyCodec_XMLCharRefReplaceError()
14 years ago
Victor Stinner
718fbf078c
_PyUnicode_CheckConsistency() ensures that the unicode string ends with a
null character
14 years ago
Benjamin Peterson
b9f4c9daad
make pointer arith c89
14 years ago
Benjamin Peterson
f3b7d86e25
use correct base ptr
14 years ago
Benjamin Peterson
2844a7a6d3
simplify and reformat
14 years ago
Victor Stinner
ece58deb9f
Close #14648 : Compute correctly maxchar in str.format() for substrin
14 years ago
Benjamin Peterson
f6622c8a3e
fix build without Py_DEBUG and DNDEBUG ( closes #14509 )
14 years ago
Victor Stinner
afb5205c48
Close #14249 : Use bit shifts instead of an union, it's more efficient.
Patch written by Serhiy Storchaka
14 years ago
Victor Stinner
e7eee01f36
Close #14249 : Use an union instead of a long to short pointer to avoid aliasing
issue. Speed up UTF-16 by 20%.
14 years ago
Antoine Pitrou
a701388de1
Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include it in the stable ABI.
14 years ago
Kristján Valur Jónsson
31668b8f7a
Issue #14288 : Serialization support for builtin iterators.
14 years ago
Benjamin Peterson
0df542985a
grammar
14 years ago
Benjamin Peterson
a8755c586e
kill this terribly outdated comment
14 years ago
Victor Stinner
0d03478b88
Remove an unused variable
14 years ago
Victor Stinner
c9590ad745
Close #14085 : remove assertions from PyUnicode_WRITE macro
Add checks in PyUnicode_WriteChar() and convert PyUnicode_New() assertion to a
test raising a Python exception.
14 years ago
Ezio Melotti
cda6b6d60d
#14081 : The sep and maxsplit parameter to str.split, bytes.split, and bytearray.split may now be passed as keyword arguments.
14 years ago
Victor Stinner
b0800dc53b
Oops, revert unwanted changes
14 years ago
Victor Stinner
abc649ddbe
Issue #14107 : fix bigmem tests on str.capitalize(), str.swapcase() and
str.title(). Compute correctly how much memory is required for the test
(memuse).
14 years ago
Antoine Pitrou
842c0f17eb
Fix compilation error under Windows (and warnings too).
14 years ago
Victor Stinner
90f50d4df9
Issue #13706 : Fix format(float, "n") for locale with non-ASCII decimal point (e.g. ps_aF)
14 years ago
Victor Stinner
41a863cb81
Issue #13706 : Fix format(int, "n") for locale with non-ASCII thousands separator
* Decode thousands separator and decimal point using PyUnicode_DecodeLocale()
(from the locale encoding), instead of decoding them implicitly from latin1
* Remove _PyUnicode_InsertThousandsGroupingLocale(), it was not used
* Change _PyUnicode_InsertThousandsGrouping() API to return the maximum
character if unicode is NULL
* Replace MIN/MAX macros by Py_MIN/Py_MAX
* stringlib/undef.h undefines STRINGLIB_IS_UNICODE
* stringlib/localeutil.h only supports Unicode
14 years ago
Victor Stinner
b429d3b09c
Fix doc of an internal function: unicode_write_cstr()
14 years ago
Antoine Pitrou
ba6bafcfbe
Fix compile failure under Windows
14 years ago
Victor Stinner
c516610f0b
Optimize str%arg for number formats: %i, %d, %u, %x, %p
Write a specialized function to write an ASCII/latin1 C char* string into a
Python Unicode string.
14 years ago
Victor Stinner
99d7ad0bb0
Micro-optimize computation of maxchar in PyUnicode_TransformDecimalToASCII()
14 years ago
Victor Stinner
da79e632c4
Micro-optimize unicode_expandtabs(): use FILL() macro to write N spaces
14 years ago
Victor Stinner
15e9ed299c
PyUnicode_New() and unicode_putchar() check for MAX_UNICODE maximum (U+10FFFF)
14 years ago
Benjamin Peterson
69e9727657
ensure no one tries to hash things before the random seed is found
14 years ago
Georg Brandl
16fa2a1097
Forgot the "empty string -> hash == 0" special case for strings.
14 years ago
Georg Brandl
2daf6ae249
Issue #13703 : add a way to randomize the hash values of basic types (str, bytes, datetime)
in order to make algorithmic complexity attacks on (e.g.) web apps much more complicated.
The environment variable PYTHONHASHSEED and the new command line flag -R control this
behavior.
14 years ago
Victor Stinner
cbe01342bc
Issue #13913 : normalize utf-8 codec name in UTF-8 decoder
14 years ago