Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
343064e8
Commit
343064e8
authored
Jun 16, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify and memoize specialization__name.
parent
750ce9c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+10
-9
No files found.
Cython/Compiler/PyrexTypes.py
View file @
343064e8
...
@@ -28,6 +28,7 @@ class BaseType(object):
...
@@ -28,6 +28,7 @@ class BaseType(object):
# List of attribute names of any subtypes
# List of attribute names of any subtypes
subtypes
=
[]
subtypes
=
[]
_empty_declaration
=
None
_empty_declaration
=
None
_specialization_name
=
None
default_format_spec
=
None
default_format_spec
=
None
def
can_coerce_to_pyobject
(
self
,
env
):
def
can_coerce_to_pyobject
(
self
,
env
):
...
@@ -48,15 +49,15 @@ class BaseType(object):
...
@@ -48,15 +49,15 @@ class BaseType(object):
return
self
.
_empty_declaration
return
self
.
_empty_declaration
def
specialization_name
(
self
):
def
specialization_name
(
self
):
if
self
.
_specialization_name
is
None
:
# This is not entirely robust.
# This is not entirely robust.
safe
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789'
common_subs
=
(
self
.
empty_declaration_code
()
all
=
[]
.
replace
(
"unsigned "
,
"unsigned_"
)
for
c
in
self
.
empty_declaration_code
().
replace
(
"unsigned "
,
"unsigned_"
).
replace
(
"long long"
,
"long_long"
).
replace
(
" "
,
"__"
):
.
replace
(
"long long"
,
"long_long"
)
if
c
in
safe
:
.
replace
(
" "
,
"__"
))
all
.
append
(
c
)
self
.
_specialization_name
=
re
.
sub
(
else
:
'[^a-zA-Z0-9_]'
,
lambda
x
:
'_%x_'
%
ord
(
x
.
group
(
0
)),
common_subs
)
all
.
append
(
'_%x_'
%
ord
(
c
))
return
self
.
_specialization_name
return
''
.
join
(
all
)
def
base_declaration_code
(
self
,
base_code
,
entity_code
):
def
base_declaration_code
(
self
,
base_code
,
entity_code
):
if
entity_code
:
if
entity_code
:
...
...
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