summaryrefslogtreecommitdiffstats
path: root/Lib/pprint.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-02 16:15:54 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-02 16:15:54 (GMT)
commit57d5c089662c43d091aff2266bff63190e019504 (patch)
treed066249e636758eb0036a25ad14d320904d1e421 /Lib/pprint.py
parentfdf239a855c82bc20df157815de947867aa2648e (diff)
downloadcpython-57d5c089662c43d091aff2266bff63190e019504.zip
cpython-57d5c089662c43d091aff2266bff63190e019504.tar.gz
cpython-57d5c089662c43d091aff2266bff63190e019504.tar.bz2
Use cached builtins.
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index a7dfe28..6155fb2 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -96,8 +96,8 @@ class _safe_key:
rv = NotImplemented
if rv is NotImplemented:
- rv = (str(type(self.obj)), id(self.obj)) < \
- (str(type(other.obj)), id(other.obj))
+ rv = (str(_type(self.obj)), _id(self.obj)) < \
+ (str(_type(other.obj)), _id(other.obj))
return rv
def _safe_tuple(t):
@@ -225,7 +225,7 @@ class PrettyPrinter:
write(typ.__name__)
write('({')
endchar = '})'
- indent += len(typ.__name__) + 1
+ indent += _len(typ.__name__) + 1
object = sorted(object, key=_safe_key)
if self._indent_per_level > 1:
write((self._indent_per_level - 1) * ' ')
@@ -240,7 +240,7 @@ class PrettyPrinter:
write(endchar)
return
- if issubclass(typ, str) and len(object) > 0 and r is str.__repr__:
+ if issubclass(typ, str) and _len(object) > 0 and r is str.__repr__:
def _str_parts(s):
"""
Return a list of string literals comprising the repr()
@@ -255,10 +255,10 @@ class PrettyPrinter:
# A list of alternating (non-space, space) strings
parts = re.split(r'(\s+)', line) + ['']
current = ''
- for i in range(0, len(parts), 2):
+ for i in range(0, _len(parts), 2):
part = parts[i] + parts[i+1]
candidate = current + part
- if len(repr(candidate)) > max_width:
+ if _len(repr(candidate)) > max_width:
if current:
yield repr(current)
current = part