Skip to content

Commit

Permalink
Use cached builtins.
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Oct 2, 2013
1 parent fdf239a commit 57d5c08
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Lib/pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def __lt__(self, other):
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):
Expand Down Expand Up @@ -225,7 +225,7 @@ def _format(self, object, stream, indent, allowance, context, level):
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) * ' ')
Expand All @@ -240,7 +240,7 @@ def _format(self, object, stream, indent, allowance, context, level):
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()
Expand All @@ -255,10 +255,10 @@ def _str_parts(s):
# 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
Expand Down

0 comments on commit 57d5c08

Please sign in to comment.