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
Gwenaël Samain
cython
Commits
ac6c463b
Commit
ac6c463b
authored
Dec 10, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cython.inline type inference
parent
efe9d6a9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
Cython/Build/Inline.py
Cython/Build/Inline.py
+11
-4
No files found.
Cython/Build/Inline.py
View file @
ac6c463b
...
@@ -51,7 +51,14 @@ def unbound_symbols(code, context=None):
...
@@ -51,7 +51,14 @@ def unbound_symbols(code, context=None):
unbound
.
append
(
name
)
unbound
.
append
(
name
)
return
unbound
return
unbound
def
get_type
(
arg
,
context
=
None
):
def
unsafe_type
(
arg
,
context
=
None
):
py_type
=
type
(
arg
)
if
py_type
is
int
:
return
'long'
else
:
return
safe_type
(
arg
,
context
)
def
safe_type
(
arg
,
context
=
None
):
py_type
=
type
(
arg
)
py_type
=
type
(
arg
)
if
py_type
in
[
list
,
tuple
,
dict
,
str
]:
if
py_type
in
[
list
,
tuple
,
dict
,
str
]:
return
py_type
.
__name__
return
py_type
.
__name__
...
@@ -61,8 +68,6 @@ def get_type(arg, context=None):
...
@@ -61,8 +68,6 @@ def get_type(arg, context=None):
return
'double'
return
'double'
elif
py_type
is
bool
:
elif
py_type
is
bool
:
return
'bint'
return
'bint'
elif
py_type
is
int
:
return
'long'
elif
'numpy'
in
sys
.
modules
and
isinstance
(
arg
,
sys
.
modules
[
'numpy'
].
ndarray
):
elif
'numpy'
in
sys
.
modules
and
isinstance
(
arg
,
sys
.
modules
[
'numpy'
].
ndarray
):
return
'numpy.ndarray[numpy.%s_t, ndim=%s]'
%
(
arg
.
dtype
.
name
,
arg
.
ndim
)
return
'numpy.ndarray[numpy.%s_t, ndim=%s]'
%
(
arg
.
dtype
.
name
,
arg
.
ndim
)
else
:
else
:
...
@@ -77,12 +82,14 @@ def get_type(arg, context=None):
...
@@ -77,12 +82,14 @@ def get_type(arg, context=None):
return
'object'
return
'object'
def
cython_inline
(
code
,
def
cython_inline
(
code
,
types
=
'aggressive'
,
get_type
=
unsafe_type
,
lib_dir
=
os
.
path
.
expanduser
(
'~/.cython/inline'
),
lib_dir
=
os
.
path
.
expanduser
(
'~/.cython/inline'
),
cython_include_dirs
=
[
'.'
],
cython_include_dirs
=
[
'.'
],
locals
=
None
,
locals
=
None
,
globals
=
None
,
globals
=
None
,
**
kwds
):
**
kwds
):
if
get_type
is
None
:
get_type
=
lambda
x
:
'object'
code
,
literals
=
strip_string_literals
(
code
)
code
,
literals
=
strip_string_literals
(
code
)
code
=
strip_common_indent
(
code
)
code
=
strip_common_indent
(
code
)
ctx
=
Context
(
include_dirs
,
default_options
)
ctx
=
Context
(
include_dirs
,
default_options
)
...
...
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