New submission from Michal Vyskocil:

pprint._safe_repr for type str uses much slower codepath by default, which does 
not makes a sense in Python3 context. Instead of simply using repr, it check 
the existence of 'locale' in sys.modules and if found, it goes one-by-one-char 
call str.isalpha() on each and apply the quoting for non-alpha chars. This is 
extremely slow, but as locale is usually in sys.modules, it's used by default.

The point of such code was because in python2, str.isalpha() depends on locale, 
so for locale-aware Python builds, there was a different path needed. But this 
does not apply for Python3, where all strings are unicode, so .isaplha() is not 
locale sensitive anymore.

----------
components: Library (Lib)
files: pprint-remove-bogus-code.patch
keywords: patch
messages: 194652
nosy: mvyskocil
priority: normal
severity: normal
status: open
title: [PATCH] remove bogus codepath from pprint._safe_repr
type: performance
Added file: http://bugs.python.org/file31193/pprint-remove-bogus-code.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18682>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to