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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
f7fb5c63
Commit
f7fb5c63
authored
May 03, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Importer.py and with statements in FusedNode
parent
9c93f96e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
56 deletions
+30
-56
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+13
-7
Cython/Compiler/FusedNode.py
Cython/Compiler/FusedNode.py
+15
-7
Cython/Compiler/Importer.py
Cython/Compiler/Importer.py
+0
-38
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+1
-3
setup.py
setup.py
+1
-1
No files found.
Cython/Compiler/Code.py
View file @
f7fb5c63
...
...
@@ -1956,17 +1956,27 @@ class PyxCodeWriter(object):
def
indent
(
self
,
levels
=
1
):
self
.
level
+=
levels
return
True
def
dedent
(
self
,
levels
=
1
):
self
.
level
-=
levels
def
indenter
(
self
,
line
):
"""
with pyx_code.indenter("for i in range(10):"):
pyx_code.putln("print i")
Instead of
with pyx_code.indenter("for i in range(10):"):
pyx_code.putln("print i")
write
if pyx_code.indenter("for i in range(10);"):
pyx_code.putln("print i")
pyx_code.dedent()
"""
self
.
putln
(
line
)
return
self
self
.
indent
()
return
True
def
getvalue
(
self
):
result
=
self
.
buffer
.
getvalue
()
...
...
@@ -2000,10 +2010,6 @@ class PyxCodeWriter(object):
def
named_insertion_point
(
self
,
name
):
setattr
(
self
,
name
,
self
.
insertion_point
())
__enter__
=
indent
def
__exit__
(
self
,
exc_value
,
exc_type
,
exc_tb
):
self
.
dedent
()
class
ClosureTempAllocator
(
object
):
def
__init__
(
self
,
klass
):
...
...
Cython/Compiler/FusedNode.py
x
→
Cython/Compiler/FusedNode.py
View file @
f7fb5c63
...
...
@@ -279,21 +279,25 @@ class FusedCFuncDefNode(StatListNode):
def
_buffer_check_numpy_dtype_setup_cases
(
self
,
pyx_code
):
"Setup some common cases to match dtypes against specializations"
with
pyx_code
.
indenter
(
"if dtype.kind in ('i', 'u'):"
):
if
pyx_code
.
indenter
(
"if dtype.kind in ('i', 'u'):"
):
pyx_code
.
putln
(
"pass"
)
pyx_code
.
named_insertion_point
(
"dtype_int"
)
pyx_code
.
dedent
()
with
pyx_code
.
indenter
(
"elif dtype.kind == 'f':"
):
if
pyx_code
.
indenter
(
"elif dtype.kind == 'f':"
):
pyx_code
.
putln
(
"pass"
)
pyx_code
.
named_insertion_point
(
"dtype_float"
)
pyx_code
.
dedent
()
with
pyx_code
.
indenter
(
"elif dtype.kind == 'c':"
):
if
pyx_code
.
indenter
(
"elif dtype.kind == 'c':"
):
pyx_code
.
putln
(
"pass"
)
pyx_code
.
named_insertion_point
(
"dtype_complex"
)
pyx_code
.
dedent
()
with
pyx_code
.
indenter
(
"elif dtype.kind == 'O':"
):
if
pyx_code
.
indenter
(
"elif dtype.kind == 'O':"
):
pyx_code
.
putln
(
"pass"
)
pyx_code
.
named_insertion_point
(
"dtype_object"
)
pyx_code
.
dedent
()
match
=
"dest_sig[{{dest_sig_idx}}] = '{{specialized_type_name}}'"
no_match
=
"dest_sig[{{dest_sig_idx}}] = None"
...
...
@@ -323,10 +327,11 @@ class FusedCFuncDefNode(StatListNode):
if
dtype
.
is_int
:
cond
+=
' and {{signed_match}}'
with
codewriter
.
indenter
(
"if %s:"
%
cond
):
if
codewriter
.
indenter
(
"if %s:"
%
cond
):
# codewriter.putln("print 'buffer match found based on numpy dtype'")
codewriter
.
putln
(
self
.
match
)
codewriter
.
putln
(
"break"
)
codewriter
.
dedent
()
def
_buffer_parse_format_string_check
(
self
,
pyx_code
,
decl_code
,
specialized_type
,
env
):
...
...
@@ -378,9 +383,9 @@ class FusedCFuncDefNode(StatListNode):
"""
from
Cython.Compiler
import
ExprNodes
if
buffer_types
:
with
pyx_code
.
indenter
(
u"else:"
):
if
pyx_code
.
indenter
(
u"else:"
):
# The first thing to find a match in this loop breaks out of the loop
with
pyx_code
.
indenter
(
u"while 1:"
):
if
pyx_code
.
indenter
(
u"while 1:"
):
pyx_code
.
put_chunk
(
u"""
if numpy is not None:
...
...
@@ -409,6 +414,9 @@ class FusedCFuncDefNode(StatListNode):
pyx_code
.
putln
(
self
.
no_match
)
pyx_code
.
putln
(
"break"
)
pyx_code
.
dedent
()
pyx_code
.
dedent
()
else
:
pyx_code
.
putln
(
"else: %s"
%
self
.
no_match
)
...
...
Cython/Compiler/Importer.py
deleted
100644 → 0
View file @
9c93f96e
"""
Transparently import a module from the compiler on which the compiler
does not depend for its bootstrapping. This way one can write code
that is not supported in certain Python versions but which is supported
by Cython.
"""
import
os
import
sys
import
imp
import
shutil
import
pyximport
# set up the PyxArgs global variable in pyximport (why is that a global :)
importers
=
pyximport
.
install
(
pyimport
=
True
)
pyximport
.
uninstall
(
*
importers
)
def
importer
(
modulename
,
version
=
None
):
try
:
# Check for an already compiled module
return
__import__
(
modulename
,
None
,
None
,
[
''
])
except
ImportError
:
pass
dirname
=
os
.
path
.
dirname
root
=
dirname
(
dirname
(
dirname
(
os
.
path
.
abspath
(
__file__
))))
filename
=
os
.
path
.
join
(
root
,
*
modulename
.
split
(
'.'
))
+
".pyx"
if
version
and
sys
.
version_info
[:
2
]
<
version
:
return
pyximport
.
load_module
(
modulename
,
filename
)
else
:
mod
=
imp
.
new_module
(
modulename
)
exec
open
(
filename
).
read
()
in
mod
.
__dict__
,
mod
.
__dict__
sys
.
modules
[
modulename
]
=
mod
return
mod
#shutil.copy(filename, os.path.splitext(filename)[0] + '.py')
#return __import__(modulename, None, None, [''])
Cython/Compiler/ParseTreeTransforms.py
View file @
f7fb5c63
...
...
@@ -18,7 +18,6 @@ from Cython.Compiler.TreeFragment import TreeFragment
from
Cython.Compiler.StringEncoding
import
EncodedString
from
Cython.Compiler.Errors
import
error
,
warning
,
CompileError
,
InternalError
from
Cython.Compiler.Code
import
UtilityCode
from
Cython.Compiler
import
Importer
import
copy
...
...
@@ -1489,8 +1488,7 @@ if VALUE is not None:
return
node
FusedNode
=
Importer
.
importer
(
"Cython.Compiler.FusedNode"
,
version
=
(
2
,
5
))
from
Cython.Compiler
import
FusedNode
node
=
FusedNode
.
FusedCFuncDefNode
(
node
,
env
)
self
.
fused_function
=
node
...
...
setup.py
View file @
f7fb5c63
...
...
@@ -112,7 +112,7 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
"Cython.Compiler.FlowControl"
,
"Cython.Compiler.Code"
,
"Cython.Runtime.refnanny"
,
"Cython.Compiler.FusedNode"
,
#
"Cython.Compiler.FusedNode",
]
if
compile_more
:
compiled_modules
.
extend
([
...
...
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