Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9f2440c5
Commit
9f2440c5
authored
Oct 02, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use cached builtins.
parent
0bfa93de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
Lib/pprint.py
Lib/pprint.py
+6
-6
No files found.
Lib/pprint.py
View file @
9f2440c5
...
@@ -96,8 +96,8 @@ class _safe_key:
...
@@ -96,8 +96,8 @@ class _safe_key:
rv
=
NotImplemented
rv
=
NotImplemented
if
rv
is
NotImplemented
:
if
rv
is
NotImplemented
:
rv
=
(
str
(
type
(
self
.
obj
)),
id
(
self
.
obj
))
<
\
rv
=
(
str
(
_type
(
self
.
obj
)),
_
id
(
self
.
obj
))
<
\
(
str
(
type
(
other
.
obj
)),
id
(
other
.
obj
))
(
str
(
_type
(
other
.
obj
)),
_
id
(
other
.
obj
))
return
rv
return
rv
def
_safe_tuple
(
t
):
def
_safe_tuple
(
t
):
...
@@ -225,7 +225,7 @@ class PrettyPrinter:
...
@@ -225,7 +225,7 @@ class PrettyPrinter:
write
(
typ
.
__name__
)
write
(
typ
.
__name__
)
write
(
'({'
)
write
(
'({'
)
endchar
=
'})'
endchar
=
'})'
indent
+=
len
(
typ
.
__name__
)
+
1
indent
+=
_
len
(
typ
.
__name__
)
+
1
object
=
sorted
(
object
,
key
=
_safe_key
)
object
=
sorted
(
object
,
key
=
_safe_key
)
if
self
.
_indent_per_level
>
1
:
if
self
.
_indent_per_level
>
1
:
write
((
self
.
_indent_per_level
-
1
)
*
' '
)
write
((
self
.
_indent_per_level
-
1
)
*
' '
)
...
@@ -240,7 +240,7 @@ class PrettyPrinter:
...
@@ -240,7 +240,7 @@ class PrettyPrinter:
write
(
endchar
)
write
(
endchar
)
return
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
):
def
_str_parts
(
s
):
"""
"""
Return a list of string literals comprising the repr()
Return a list of string literals comprising the repr()
...
@@ -255,10 +255,10 @@ class PrettyPrinter:
...
@@ -255,10 +255,10 @@ class PrettyPrinter:
# A list of alternating (non-space, space) strings
# A list of alternating (non-space, space) strings
parts
=
re
.
split
(
r'(\
s+)
', line) + ['']
parts
=
re
.
split
(
r'(\
s+)
', line) + ['']
current = ''
current = ''
for i in range(0, len(parts), 2):
for i in range(0,
_
len(parts), 2):
part = parts[i] + parts[i+1]
part = parts[i] + parts[i+1]
candidate = current + part
candidate = current + part
if len(repr(candidate)) > max_width:
if
_
len(repr(candidate)) > max_width:
if current:
if current:
yield repr(current)
yield repr(current)
current = part
current = part
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment