Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(256883)

#19424: _warnings: patch to avoid conversions from/to UTF-8

Can't Edit
Can't Publish+Mail
Start Review
Created:
5 years, 9 months ago by vstinner
Modified:
5 years, 9 months ago
Reviewers:
storchaka
CC:
haypo, ezio.melotti, Arfrever, devnull_psf.upfronthosting.co.za, Zach Ware, storchaka, vajrasky
Visibility:
Public.

Patch Set 1 #

Total comments: 4

Patch Set 2 #

Patch Set 3 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Objects/unicodeobject.c View 1 2 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 1
storchaka_gmail.com
5 years, 9 months ago #1
http://bugs.python.org/review/19424/diff/9732/Python/_warnings.c
File Python/_warnings.c (right):

http://bugs.python.org/review/19424/diff/9732/Python/_warnings.c#newcode198
Python/_warnings.c:198: len = PyUnicode_GetLength(filename);
Can a filename be None?

http://bugs.python.org/review/19424/diff/9732/Python/_warnings.c#newcode290
Python/_warnings.c:290: ch = PyUnicode_READ(kind, data, i);
This is a pessimization. A loop with PyUnicode_READ() is much slower than
scanning 1-byte string. _PyUnicode_AsString() in most cases is very fast (when
source line is ASCII only).

http://bugs.python.org/review/19424/diff/9732/Python/_warnings.c#newcode295
Python/_warnings.c:295: if (i != 0) {
This optimization is redundant. PyUnicode_Substring(string, 0, len) returns the
string itself, without copying.

http://bugs.python.org/review/19424/diff/9732/Python/_warnings.c#newcode382
Python/_warnings.c:382: if (PyUnicode_CompareWithASCIIString(action, "error") ==
0) {
This is a pessimization. PyUnicode_CompareWithASCIIString() is much slower than
strcmp().
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+