Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
nexedi
cython
Commits
f6762fad
Commit
f6762fad
authored
Dec 13, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove trailing whitespace.
parent
671e6a53
Changes
235
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
235 changed files
with
2969 additions
and
2969 deletions
+2969
-2969
COPYING.txt
COPYING.txt
+2
-2
Dependencies.py
Cython/Build/Dependencies.py
+25
-25
Inline.py
Cython/Build/Inline.py
+3
-3
TestInline.py
Cython/Build/Tests/TestInline.py
+1
-1
CodeWriter.py
Cython/CodeWriter.py
+27
-27
AnalysedTreeTransforms.py
Cython/Compiler/AnalysedTreeTransforms.py
+1
-1
Annotate.py
Cython/Compiler/Annotate.py
+18
-18
AutoDocTransforms.py
Cython/Compiler/AutoDocTransforms.py
+2
-2
Buffer.py
Cython/Compiler/Buffer.py
+28
-28
Builtin.py
Cython/Compiler/Builtin.py
+4
-4
CmdLine.py
Cython/Compiler/CmdLine.py
+4
-4
Code.py
Cython/Compiler/Code.py
+64
-64
ControlFlow.py
Cython/Compiler/ControlFlow.py
+23
-23
CythonScope.py
Cython/Compiler/CythonScope.py
+6
-6
Errors.py
Cython/Compiler/Errors.py
+7
-7
ExprNodes.py
Cython/Compiler/ExprNodes.py
+484
-484
Interpreter.py
Cython/Compiler/Interpreter.py
+2
-2
Lexicon.py
Cython/Compiler/Lexicon.py
+27
-27
Main.py
Cython/Compiler/Main.py
+27
-27
ModuleNode.py
Cython/Compiler/ModuleNode.py
+87
-87
Nodes.py
Cython/Compiler/Nodes.py
+293
-293
Optimize.py
Cython/Compiler/Optimize.py
+19
-19
Options.py
Cython/Compiler/Options.py
+19
-19
ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+81
-81
Parsing.py
Cython/Compiler/Parsing.py
+52
-52
PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+180
-180
Scanning.py
Cython/Compiler/Scanning.py
+26
-26
Symtab.py
Cython/Compiler/Symtab.py
+131
-131
TestBuffer.py
Cython/Compiler/Tests/TestBuffer.py
+4
-4
TestDecorators.py
Cython/Compiler/Tests/TestDecorators.py
+1
-1
TestParseTreeTransforms.py
Cython/Compiler/Tests/TestParseTreeTransforms.py
+14
-14
TestTreeFragment.py
Cython/Compiler/Tests/TestTreeFragment.py
+3
-3
TreeFragment.py
Cython/Compiler/TreeFragment.py
+13
-13
TreePath.py
Cython/Compiler/TreePath.py
+2
-2
TypeInference.py
Cython/Compiler/TypeInference.py
+22
-22
TypeSlots.py
Cython/Compiler/TypeSlots.py
+53
-53
UtilNodes.py
Cython/Compiler/UtilNodes.py
+13
-13
Visitor.py
Cython/Compiler/Visitor.py
+14
-14
Cygdb.py
Cython/Debugger/Cygdb.py
+11
-11
DebugWriter.py
Cython/Debugger/DebugWriter.py
+7
-7
TestLibCython.py
Cython/Debugger/Tests/TestLibCython.py
+35
-35
cfuncs.c
Cython/Debugger/Tests/cfuncs.c
+1
-1
test_libcython_in_gdb.py
Cython/Debugger/Tests/test_libcython_in_gdb.py
+74
-74
test_libpython_in_gdb.py
Cython/Debugger/Tests/test_libpython_in_gdb.py
+30
-30
libcython.py
Cython/Debugger/libcython.py
+187
-187
libpython.py
Cython/Debugger/libpython.py
+157
-157
__init__.py
Cython/Distutils/__init__.py
+1
-1
build_ext.py
Cython/Distutils/build_ext.py
+16
-16
__init__.pxd
Cython/Includes/cpython/__init__.pxd
+5
-5
bool.pxd
Cython/Includes/cpython/bool.pxd
+3
-3
buffer.pxd
Cython/Includes/cpython/buffer.pxd
+2
-2
bytes.pxd
Cython/Includes/cpython/bytes.pxd
+8
-8
complex.pxd
Cython/Includes/cpython/complex.pxd
+5
-5
dict.pxd
Cython/Includes/cpython/dict.pxd
+6
-6
exc.pxd
Cython/Includes/cpython/exc.pxd
+3
-3
float.pxd
Cython/Includes/cpython/float.pxd
+4
-4
function.pxd
Cython/Includes/cpython/function.pxd
+4
-4
instance.pxd
Cython/Includes/cpython/instance.pxd
+3
-3
int.pxd
Cython/Includes/cpython/int.pxd
+3
-3
iterator.pxd
Cython/Includes/cpython/iterator.pxd
+1
-1
list.pxd
Cython/Includes/cpython/list.pxd
+5
-5
long.pxd
Cython/Includes/cpython/long.pxd
+9
-9
mem.pxd
Cython/Includes/cpython/mem.pxd
+1
-1
method.pxd
Cython/Includes/cpython/method.pxd
+6
-6
module.pxd
Cython/Includes/cpython/module.pxd
+4
-4
number.pxd
Cython/Includes/cpython/number.pxd
+6
-6
object.pxd
Cython/Includes/cpython/object.pxd
+4
-4
pycapsule.pxd
Cython/Includes/cpython/pycapsule.pxd
+1
-1
ref.pxd
Cython/Includes/cpython/ref.pxd
+1
-1
sequence.pxd
Cython/Includes/cpython/sequence.pxd
+2
-2
set.pxd
Cython/Includes/cpython/set.pxd
+5
-5
string.pxd
Cython/Includes/cpython/string.pxd
+8
-8
tuple.pxd
Cython/Includes/cpython/tuple.pxd
+4
-4
type.pxd
Cython/Includes/cpython/type.pxd
+3
-3
unicode.pxd
Cython/Includes/cpython/unicode.pxd
+14
-14
signal.pxd
Cython/Includes/libc/signal.pxd
+1
-1
stdio.pxd
Cython/Includes/libc/stdio.pxd
+1
-1
stdlib.pxd
Cython/Includes/libc/stdlib.pxd
+2
-2
string.pxd
Cython/Includes/libc/string.pxd
+1
-1
numpy.pxd
Cython/Includes/numpy.pxd
+19
-19
fcntl.pxd
Cython/Includes/posix/fcntl.pxd
+1
-1
unistd.pxd
Cython/Includes/posix/unistd.pxd
+1
-1
Actions.py
Cython/Plex/Actions.py
+3
-3
DFA.py
Cython/Plex/DFA.py
+3
-3
Errors.py
Cython/Plex/Errors.py
+1
-1
Lexicons.py
Cython/Plex/Lexicons.py
+1
-1
Machines.py
Cython/Plex/Machines.py
+14
-14
Regexps.py
Cython/Plex/Regexps.py
+19
-19
Scanners.pxd
Cython/Plex/Scanners.pxd
+1
-1
Scanners.py
Cython/Plex/Scanners.py
+3
-3
Traditional.py
Cython/Plex/Traditional.py
+12
-12
Transitions.py
Cython/Plex/Transitions.py
+29
-29
Shadow.py
Cython/Shadow.py
+13
-13
StringIOTree.py
Cython/StringIOTree.py
+1
-1
TestUtils.py
Cython/TestUtils.py
+10
-10
TestCodeWriter.py
Cython/Tests/TestCodeWriter.py
+5
-5
TestStringIOTree.py
Cython/Tests/TestStringIOTree.py
+10
-10
xmlrunner.py
Cython/Tests/xmlrunner.py
+54
-54
Utils.py
Cython/Utils.py
+2
-2
__init__.py
Cython/__init__.py
+1
-1
INSTALL.txt
INSTALL.txt
+2
-2
ToDo.txt
ToDo.txt
+1
-1
USAGE.txt
USAGE.txt
+1
-1
b_extimpinherit.pyx
tests/broken/b_extimpinherit.pyx
+1
-1
cdefemptysue.pyx
tests/broken/cdefemptysue.pyx
+3
-3
cdefexternblock.pyx
tests/broken/cdefexternblock.pyx
+3
-3
externsue.pyx
tests/broken/externsue.pyx
+2
-2
getattr.pyx
tests/broken/getattr.pyx
+1
-1
r_excval.pyx
tests/broken/r_excval.pyx
+1
-1
r_extcmethod.pyx
tests/broken/r_extcmethod.pyx
+1
-1
r_extimpinherit.pyx
tests/broken/r_extimpinherit.pyx
+1
-1
r_extinherit.pyx
tests/broken/r_extinherit.pyx
+2
-2
r_extmember.pyx
tests/broken/r_extmember.pyx
+2
-2
r_extnumeric2.pyx
tests/broken/r_extnumeric2.pyx
+3
-3
r_extproperty.pyx
tests/broken/r_extproperty.pyx
+4
-4
bugs.txt
tests/bugs.txt
+2
-2
a_capi.pyx
tests/compile/a_capi.pyx
+1
-1
c_directives.pyx
tests/compile/c_directives.pyx
+2
-2
cargdef.pyx
tests/compile/cargdef.pyx
+3
-3
cassign.pyx
tests/compile/cassign.pyx
+2
-2
cast_ctypedef_array_T518.pyx
tests/compile/cast_ctypedef_array_T518.pyx
+4
-4
cenum.pyx
tests/compile/cenum.pyx
+1
-1
docstrings.pyx
tests/compile/docstrings.pyx
+1
-1
extcmethcall.pyx
tests/compile/extcmethcall.pyx
+1
-1
extcoerce.pyx
tests/compile/extcoerce.pyx
+1
-1
extdelattr.pyx
tests/compile/extdelattr.pyx
+1
-1
extdelitem.pyx
tests/compile/extdelitem.pyx
+1
-1
extdelslice.pyx
tests/compile/extdelslice.pyx
+1
-1
extgetattr.pyx
tests/compile/extgetattr.pyx
+1
-1
extinheritdel.pyx
tests/compile/extinheritdel.pyx
+1
-1
extinheritset.pyx
tests/compile/extinheritset.pyx
+1
-1
extpropertyall.pyx
tests/compile/extpropertyall.pyx
+3
-3
extsetattr.pyx
tests/compile/extsetattr.pyx
+1
-1
extsetitem.pyx
tests/compile/extsetitem.pyx
+1
-1
extsetslice.pyx
tests/compile/extsetslice.pyx
+1
-1
for.pyx
tests/compile/for.pyx
+7
-7
fromimport.pyx
tests/compile/fromimport.pyx
+1
-1
gencall.pyx
tests/compile/gencall.pyx
+1
-1
huss2.pyx
tests/compile/huss2.pyx
+1
-1
ia_cdefblock.pyx
tests/compile/ia_cdefblock.pyx
+4
-4
import.pyx
tests/compile/import.pyx
+1
-1
index.pyx
tests/compile/index.pyx
+1
-1
jiba3.pyx
tests/compile/jiba3.pyx
+1
-1
libc_signal.pyx
tests/compile/libc_signal.pyx
+1
-1
point.h
tests/compile/point.h
+1
-1
pylong.pyx
tests/compile/pylong.pyx
+4
-4
tryexcept.pyx
tests/compile/tryexcept.pyx
+11
-11
tryfinally.pyx
tests/compile/tryfinally.pyx
+4
-4
types_and_names.pxd
tests/compile/types_and_names.pxd
+3
-3
types_and_names.pyx
tests/compile/types_and_names.pyx
+2
-2
while.pyx
tests/compile/while.pyx
+5
-5
e_ass.pyx
tests/errors/e_ass.pyx
+1
-1
e_badtypeuse.pyx
tests/errors/e_badtypeuse.pyx
+1
-1
e_bufaccess.pyx
tests/errors/e_bufaccess.pyx
+1
-1
e_cenum.pyx
tests/errors/e_cenum.pyx
+1
-1
e_ctypedefornot.pyx
tests/errors/e_ctypedefornot.pyx
+1
-1
e_slice.pyx
tests/errors/e_slice.pyx
+2
-2
e_tempcast.pyx
tests/errors/e_tempcast.pyx
+1
-1
encoding.pyx
tests/errors/encoding.pyx
+1
-1
nogil.pyx
tests/errors/nogil.pyx
+1
-1
__getattribute_subclasses__.pyx
tests/run/__getattribute_subclasses__.pyx
+5
-5
autotestdict.pyx
tests/run/autotestdict.pyx
+1
-1
autotestdict_all.pyx
tests/run/autotestdict_all.pyx
+1
-1
autotestdict_cdef.pyx
tests/run/autotestdict_cdef.pyx
+1
-1
bufaccess.pyx
tests/run/bufaccess.pyx
+40
-40
buffmt.pyx
tests/run/buffmt.pyx
+15
-15
call_crash.pyx
tests/run/call_crash.pyx
+3
-3
callargs.pyx
tests/run/callargs.pyx
+2
-2
cdefassign.pyx
tests/run/cdefassign.pyx
+1
-1
cdefoptargs.pyx
tests/run/cdefoptargs.pyx
+1
-1
closure_decorators_T478.pyx
tests/run/closure_decorators_T478.pyx
+4
-4
complex_numbers_T305.pyx
tests/run/complex_numbers_T305.pyx
+1
-1
cpp_classes.pyx
tests/run/cpp_classes.pyx
+4
-4
cpp_exceptions.pyx
tests/run/cpp_exceptions.pyx
+1
-1
cpp_namespaces_helper.h
tests/run/cpp_namespaces_helper.h
+10
-10
cpp_nested_templates.pyx
tests/run/cpp_nested_templates.pyx
+3
-3
cpp_operators.pyx
tests/run/cpp_operators.pyx
+2
-2
cpp_operators_helper.h
tests/run/cpp_operators_helper.h
+3
-3
cpp_stl.pyx
tests/run/cpp_stl.pyx
+1
-1
cpp_templates.pyx
tests/run/cpp_templates.pyx
+1
-1
ctruthtests.pyx
tests/run/ctruthtests.pyx
+1
-1
cython_includes.pyx
tests/run/cython_includes.pyx
+1
-1
dict_getitem.pyx
tests/run/dict_getitem.pyx
+1
-1
exceptionrefcount.pyx
tests/run/exceptionrefcount.pyx
+1
-1
extcmethod.pyx
tests/run/extcmethod.pyx
+1
-1
extern_builtins_T258.pyx
tests/run/extern_builtins_T258.pyx
+1
-1
extpropertyref.pyx
tests/run/extpropertyref.pyx
+1
-1
exttype.pyx
tests/run/exttype.pyx
+2
-2
for_decrement.pyx
tests/run/for_decrement.pyx
+2
-2
function_as_method_T494.pyx
tests/run/function_as_method_T494.pyx
+1
-1
function_binding_T494.pyx
tests/run/function_binding_T494.pyx
+1
-1
hash_T326.pyx
tests/run/hash_T326.pyx
+1
-1
if.pyx
tests/run/if.pyx
+1
-1
ifelseexpr_T267.pyx
tests/run/ifelseexpr_T267.pyx
+1
-1
importfrom.pyx
tests/run/importfrom.pyx
+1
-1
index.pyx
tests/run/index.pyx
+1
-1
inplace.pyx
tests/run/inplace.pyx
+4
-4
int_literals.pyx
tests/run/int_literals.pyx
+2
-2
knuth_man_or_boy_test.pyx
tests/run/knuth_man_or_boy_test.pyx
+1
-1
large_consts_T237.pyx
tests/run/large_consts_T237.pyx
+1
-1
list_pop.pyx
tests/run/list_pop.pyx
+8
-8
literals.pyx
tests/run/literals.pyx
+2
-2
modbody.pyx
tests/run/modbody.pyx
+1
-1
moduletryexcept.pyx
tests/run/moduletryexcept.pyx
+2
-2
numpy_common.pxi
tests/run/numpy_common.pxi
+1
-1
numpy_test.pyx
tests/run/numpy_test.pyx
+14
-14
pinard5.pyx
tests/run/pinard5.pyx
+1
-1
pure.pyx
tests/run/pure.pyx
+2
-2
pure_py.py
tests/run/pure_py.py
+2
-2
r_extcomplex2.pyx
tests/run/r_extcomplex2.pyx
+3
-3
r_forloop.pyx
tests/run/r_forloop.pyx
+1
-1
r_huss3.pyx
tests/run/r_huss3.pyx
+1
-1
r_pythonapi.pyx
tests/run/r_pythonapi.pyx
+1
-1
r_spamtype.pyx
tests/run/r_spamtype.pyx
+4
-4
shapes.h
tests/run/shapes.h
+4
-4
simpcall.pyx
tests/run/simpcall.pyx
+2
-2
slice3.pyx
tests/run/slice3.pyx
+1
-1
slice_ptr.pyx
tests/run/slice_ptr.pyx
+1
-1
special_methods_T561.pyx
tests/run/special_methods_T561.pyx
+5
-5
special_methods_T561_py2.pyx
tests/run/special_methods_T561_py2.pyx
+1
-1
strfunction.pyx
tests/run/strfunction.pyx
+1
-1
strliterals.pyx
tests/run/strliterals.pyx
+1
-1
struct_conversion.pyx
tests/run/struct_conversion.pyx
+3
-3
subop.pyx
tests/run/subop.pyx
+1
-1
temps_corner1.pyx
tests/run/temps_corner1.pyx
+1
-1
type_inference.pyx
tests/run/type_inference.pyx
+3
-3
typedfieldbug_T303.pyx
tests/run/typedfieldbug_T303.pyx
+1
-1
typeof.pyx
tests/run/typeof.pyx
+1
-1
unicodemethods.pyx
tests/run/unicodemethods.pyx
+18
-18
unsignedbehaviour_T184.pyx
tests/run/unsignedbehaviour_T184.pyx
+1
-1
withstat.pyx
tests/run/withstat.pyx
+4
-4
cpp_overload_wrapper_lib.cpp
tests/wrappers/cpp_overload_wrapper_lib.cpp
+1
-1
cpp_overload_wrapper_lib.h
tests/wrappers/cpp_overload_wrapper_lib.h
+2
-2
cpp_references.pyx
tests/wrappers/cpp_references.pyx
+1
-1
cppwrap_lib.h
tests/wrappers/cppwrap_lib.h
+2
-2
No files found.
COPYING.txt
View file @
f6762fad
...
...
@@ -5,9 +5,9 @@ redistribute, modify and distribute modified versions."
------------------
Cython, which derives from Pyrex, is licensed under the Python
Software Foundation License. More precisely, all modifications
Software Foundation License. More precisely, all modifications
made to go from Pyrex to Cython are so licensed.
See LICENSE.txt for more details.
Cython/Build/Dependencies.py
View file @
f6762fad
...
...
@@ -36,7 +36,7 @@ def parse_list(s):
return
literals
[
literal
[
1
:
-
1
]]
else
:
return
literal
return
[
unquote
(
item
)
for
item
in
s
.
split
(
delimiter
)]
transitive_str
=
object
()
...
...
@@ -70,7 +70,7 @@ def line_iter(source):
start
=
end
+
1
class
DistutilsInfo
(
object
):
def
__init__
(
self
,
source
=
None
,
exn
=
None
):
self
.
values
=
{}
if
source
is
not
None
:
...
...
@@ -97,7 +97,7 @@ class DistutilsInfo(object):
value
=
getattr
(
exn
,
key
,
None
)
if
value
:
self
.
values
[
key
]
=
value
def
merge
(
self
,
other
):
if
other
is
None
:
return
self
...
...
@@ -114,7 +114,7 @@ class DistutilsInfo(object):
else
:
self
.
values
[
key
]
=
value
return
self
def
subs
(
self
,
aliases
):
if
aliases
is
None
:
return
self
...
...
@@ -140,9 +140,9 @@ class DistutilsInfo(object):
def
strip_string_literals
(
code
,
prefix
=
'__Pyx_L'
):
"""
Normalizes every string literal to be of the form '__Pyx_Lxxx',
Normalizes every string literal to be of the form '__Pyx_Lxxx',
returning the normalized code and a mapping of labels to
string literals.
string literals.
"""
new_code
=
[]
literals
=
{}
...
...
@@ -156,7 +156,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
double_q
=
code
.
find
(
'"'
,
q
)
q
=
min
(
single_q
,
double_q
)
if
q
==
-
1
:
q
=
max
(
single_q
,
double_q
)
# We're done.
if
q
==
-
1
and
hash_mark
==
-
1
:
new_code
.
append
(
code
[
start
:])
...
...
@@ -181,7 +181,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
start
=
q
else
:
q
+=
1
# Process comment.
elif
-
1
!=
hash_mark
and
(
hash_mark
<
q
or
q
==
-
1
):
end
=
code
.
find
(
'
\n
'
,
hash_mark
)
...
...
@@ -212,7 +212,7 @@ def strip_string_literals(code, prefix='__Pyx_L'):
new_code
.
append
(
code
[
start
:
end
])
start
=
q
q
+=
len
(
in_quote
)
return
""
.
join
(
new_code
),
literals
...
...
@@ -245,16 +245,16 @@ def parse_dependencies(source_filename):
class
DependencyTree
(
object
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
_transitive_cache
=
{}
#@cached_method
def
parse_dependencies
(
self
,
source_filename
):
return
parse_dependencies
(
source_filename
)
parse_dependencies
=
cached_method
(
parse_dependencies
)
#@cached_method
def
cimports_and_externs
(
self
,
filename
):
cimports
,
includes
,
externs
=
self
.
parse_dependencies
(
filename
)[:
3
]
...
...
@@ -272,10 +272,10 @@ class DependencyTree(object):
print
(
"Unable to locate '
%
s' referenced from '
%
s'"
%
(
filename
,
include
))
return
tuple
(
cimports
),
tuple
(
externs
)
cimports_and_externs
=
cached_method
(
cimports_and_externs
)
def
cimports
(
self
,
filename
):
return
self
.
cimports_and_externs
(
filename
)[
0
]
#@cached_method
def
package
(
self
,
filename
):
dir
=
os
.
path
.
dirname
(
filename
)
...
...
@@ -284,13 +284,13 @@ class DependencyTree(object):
else
:
return
()
package
=
cached_method
(
package
)
#@cached_method
def
fully_qualifeid_name
(
self
,
filename
):
module
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
filename
))[
0
]
return
'.'
.
join
(
self
.
package
(
filename
)
+
(
module
,))
fully_qualifeid_name
=
cached_method
(
fully_qualifeid_name
)
def
find_pxd
(
self
,
module
,
filename
=
None
):
if
module
[
0
]
==
'.'
:
raise
NotImplementedError
(
"New relative imports."
)
...
...
@@ -301,7 +301,7 @@ class DependencyTree(object):
return
pxd
return
self
.
context
.
find_pxd_file
(
module
,
None
)
find_pxd
=
cached_method
(
find_pxd
)
#@cached_method
def
cimported_files
(
self
,
filename
):
if
filename
[
-
4
:]
==
'.pyx'
and
os
.
path
.
exists
(
filename
[:
-
4
]
+
'.pxd'
):
...
...
@@ -316,33 +316,33 @@ class DependencyTree(object):
print
(
"
\n\t
"
.
join
(
b
))
return
tuple
(
self_pxd
+
filter
(
None
,
[
self
.
find_pxd
(
m
,
filename
)
for
m
in
self
.
cimports
(
filename
)]))
cimported_files
=
cached_method
(
cimported_files
)
def
immediate_dependencies
(
self
,
filename
):
all
=
list
(
self
.
cimported_files
(
filename
))
for
extern
in
sum
(
self
.
cimports_and_externs
(
filename
),
()):
all
.
append
(
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
filename
),
extern
)))
return
tuple
(
all
)
#@cached_method
def
timestamp
(
self
,
filename
):
return
os
.
path
.
getmtime
(
filename
)
timestamp
=
cached_method
(
timestamp
)
def
extract_timestamp
(
self
,
filename
):
# TODO: .h files from extern blocks
return
self
.
timestamp
(
filename
),
filename
def
newest_dependency
(
self
,
filename
):
return
self
.
transitive_merge
(
filename
,
self
.
extract_timestamp
,
max
)
def
distutils_info0
(
self
,
filename
):
return
self
.
parse_dependencies
(
filename
)[
3
]
def
distutils_info
(
self
,
filename
,
aliases
=
None
,
base
=
None
):
return
(
self
.
transitive_merge
(
filename
,
self
.
distutils_info0
,
DistutilsInfo
.
merge
)
.
subs
(
aliases
)
.
merge
(
base
))
def
transitive_merge
(
self
,
node
,
extract
,
merge
):
try
:
seen
=
self
.
_transitive_cache
[
extract
,
merge
]
...
...
@@ -350,7 +350,7 @@ class DependencyTree(object):
seen
=
self
.
_transitive_cache
[
extract
,
merge
]
=
{}
return
self
.
transitive_merge_helper
(
node
,
extract
,
merge
,
seen
,
{},
self
.
cimported_files
)[
0
]
def
transitive_merge_helper
(
self
,
node
,
extract
,
merge
,
seen
,
stack
,
outgoing
):
if
node
in
seen
:
return
seen
[
node
],
None
...
...
Cython/Build/Inline.py
View file @
f6762fad
...
...
@@ -88,7 +88,7 @@ def safe_type(arg, context=None):
return
'
%
s.
%
s'
%
(
base_type
.
__module__
,
base_type
.
__name__
)
return
'object'
def
cython_inline
(
code
,
def
cython_inline
(
code
,
get_type
=
unsafe_type
,
lib_dir
=
os
.
path
.
expanduser
(
'~/.cython/inline'
),
cython_include_dirs
=
[
'.'
],
...
...
@@ -252,14 +252,14 @@ def get_body(source):
else
:
return
source
[
ix
+
1
:]
# Lots to be done here... It would be especially cool if compiled functions
# Lots to be done here... It would be especially cool if compiled functions
# could invoke each other quickly.
class
RuntimeCompiledFunction
(
object
):
def
__init__
(
self
,
f
):
self
.
_f
=
f
self
.
_body
=
get_body
(
inspect
.
getsource
(
f
))
def
__call__
(
self
,
*
args
,
**
kwds
):
all
=
getcallargs
(
self
.
_f
,
*
args
,
**
kwds
)
return
cython_inline
(
self
.
_body
,
locals
=
self
.
_f
.
func_globals
,
globals
=
self
.
_f
.
func_globals
,
**
all
)
Cython/Build/Tests/TestInline.py
View file @
f6762fad
...
...
@@ -32,7 +32,7 @@ class TestInline(CythonTest):
self
.
assertEquals
(
inline
(
"return global_value + 1"
,
**
test_kwds
),
global_value
+
1
)
if
has_numpy
:
def
test_numpy
(
self
):
import
numpy
a
=
numpy
.
ndarray
((
10
,
20
))
...
...
Cython/CodeWriter.py
View file @
f6762fad
...
...
@@ -14,14 +14,14 @@ class LinesResult(object):
def
__init__
(
self
):
self
.
lines
=
[]
self
.
s
=
u""
def
put
(
self
,
s
):
self
.
s
+=
s
def
newline
(
self
):
self
.
lines
.
append
(
self
.
s
)
self
.
s
=
u""
def
putline
(
self
,
s
):
self
.
put
(
s
)
self
.
newline
()
...
...
@@ -29,7 +29,7 @@ class LinesResult(object):
class
CodeWriter
(
TreeVisitor
):
indent_string
=
u" "
def
__init__
(
self
,
result
=
None
):
super
(
CodeWriter
,
self
)
.
__init__
()
if
result
is
None
:
...
...
@@ -38,22 +38,22 @@ class CodeWriter(TreeVisitor):
self
.
numindents
=
0
self
.
tempnames
=
{}
self
.
tempblockindex
=
0
def
write
(
self
,
tree
):
self
.
visit
(
tree
)
def
indent
(
self
):
self
.
numindents
+=
1
def
dedent
(
self
):
self
.
numindents
-=
1
def
startline
(
self
,
s
=
u""
):
self
.
result
.
put
(
self
.
indent_string
*
self
.
numindents
+
s
)
def
put
(
self
,
s
):
self
.
result
.
put
(
s
)
def
endline
(
self
,
s
=
u""
):
self
.
result
.
putline
(
s
)
...
...
@@ -70,13 +70,13 @@ class CodeWriter(TreeVisitor):
self
.
visit
(
item
.
default
)
self
.
put
(
u", "
)
self
.
visit
(
items
[
-
1
])
def
visit_Node
(
self
,
node
):
raise
AssertionError
(
"Node not handled by serializer:
%
r"
%
node
)
def
visit_ModuleNode
(
self
,
node
):
self
.
visitchildren
(
node
)
def
visit_StatListNode
(
self
,
node
):
self
.
visitchildren
(
node
)
...
...
@@ -87,7 +87,7 @@ class CodeWriter(TreeVisitor):
self
.
indent
()
self
.
visit
(
node
.
body
)
self
.
dedent
()
def
visit_CArgDeclNode
(
self
,
node
):
if
node
.
base_type
.
name
is
not
None
:
self
.
visit
(
node
.
base_type
)
...
...
@@ -96,10 +96,10 @@ class CodeWriter(TreeVisitor):
if
node
.
default
is
not
None
:
self
.
put
(
u" = "
)
self
.
visit
(
node
.
default
)
def
visit_CNameDeclaratorNode
(
self
,
node
):
self
.
put
(
node
.
name
)
def
visit_CSimpleBaseTypeNode
(
self
,
node
):
# See Parsing.p_sign_and_longness
if
node
.
is_basic_c_type
:
...
...
@@ -108,16 +108,16 @@ class CodeWriter(TreeVisitor):
self
.
put
(
"short "
*
-
node
.
longness
)
elif
node
.
longness
>
0
:
self
.
put
(
"long "
*
node
.
longness
)
self
.
put
(
node
.
name
)
def
visit_SingleAssignmentNode
(
self
,
node
):
self
.
startline
()
self
.
visit
(
node
.
lhs
)
self
.
put
(
u" = "
)
self
.
visit
(
node
.
rhs
)
self
.
endline
()
def
visit_CascadedAssignmentNode
(
self
,
node
):
self
.
startline
()
for
lhs
in
node
.
lhs_list
:
...
...
@@ -125,10 +125,10 @@ class CodeWriter(TreeVisitor):
self
.
put
(
u" = "
)
self
.
visit
(
node
.
rhs
)
self
.
endline
()
def
visit_NameNode
(
self
,
node
):
self
.
put
(
node
.
name
)
def
visit_IntNode
(
self
,
node
):
self
.
put
(
node
.
value
)
...
...
@@ -164,7 +164,7 @@ class CodeWriter(TreeVisitor):
def
visit_PassStatNode
(
self
,
node
):
self
.
startline
(
u"pass"
)
self
.
endline
()
def
visit_PrintStatNode
(
self
,
node
):
self
.
startline
(
u"print "
)
self
.
comma_separated_list
(
node
.
arg_tuple
.
args
)
...
...
@@ -176,7 +176,7 @@ class CodeWriter(TreeVisitor):
self
.
visit
(
node
.
operand1
)
self
.
put
(
u"
%
s "
%
node
.
operator
)
self
.
visit
(
node
.
operand2
)
def
visit_CVarDefNode
(
self
,
node
):
self
.
startline
(
u"cdef "
)
self
.
visit
(
node
.
base_type
)
...
...
@@ -201,7 +201,7 @@ class CodeWriter(TreeVisitor):
def
visit_SequenceNode
(
self
,
node
):
self
.
comma_separated_list
(
node
.
args
)
# Might need to discover whether we need () around tuples...hmm...
def
visit_SimpleCallNode
(
self
,
node
):
self
.
visit
(
node
.
function
)
self
.
put
(
u"("
)
...
...
@@ -224,14 +224,14 @@ class CodeWriter(TreeVisitor):
self
.
startline
()
self
.
visit
(
node
.
expr
)
self
.
endline
()
def
visit_InPlaceAssignmentNode
(
self
,
node
):
self
.
startline
()
self
.
visit
(
node
.
lhs
)
self
.
put
(
u"
%
s= "
%
node
.
operator
)
self
.
visit
(
node
.
rhs
)
self
.
endline
()
def
visit_WithStatNode
(
self
,
node
):
self
.
startline
()
self
.
put
(
u"with "
)
...
...
@@ -243,7 +243,7 @@ class CodeWriter(TreeVisitor):
self
.
indent
()
self
.
visit
(
node
.
body
)
self
.
dedent
()
def
visit_AttributeNode
(
self
,
node
):
self
.
visit
(
node
.
obj
)
self
.
put
(
u".
%
s"
%
node
.
attribute
)
...
...
Cython/Compiler/AnalysedTreeTransforms.py
View file @
f6762fad
...
...
@@ -11,7 +11,7 @@ import Symtab
class
AutoTestDictTransform
(
ScopeTrackingTransform
):
# Handles autotestdict directive
blacklist
=
[
'__cinit__'
,
'__dealloc__'
,
'__richcmp__'
,
blacklist
=
[
'__cinit__'
,
'__dealloc__'
,
'__richcmp__'
,
'__nonzero__'
,
'__bool__'
,
'__len__'
,
'__contains__'
]
...
...
Cython/Compiler/Annotate.py
View file @
f6762fad
...
...
@@ -12,9 +12,9 @@ from Cython import Utils
# need one-characters subsitutions (for now) so offsets aren't off
special_chars
=
[(
u'<'
,
u'
\xF0
'
,
u'<'
),
(
u'>'
,
u'
\xF1
'
,
u'>'
),
(
u'>'
,
u'
\xF1
'
,
u'>'
),
(
u'&'
,
u'
\xF2
'
,
u'&'
)]
line_pos_comment
=
re
.
compile
(
r'/\*.*?<<<<<<<<<<<<<<.*?\*/\n*'
,
re
.
DOTALL
)
class
AnnotationCCodeWriter
(
CCodeWriter
):
...
...
@@ -32,14 +32,14 @@ class AnnotationCCodeWriter(CCodeWriter):
self
.
annotations
=
create_from
.
annotations
self
.
code
=
create_from
.
code
self
.
last_pos
=
create_from
.
last_pos
def
create_new
(
self
,
create_from
,
buffer
,
copy_formatting
):
return
AnnotationCCodeWriter
(
create_from
,
buffer
,
copy_formatting
)
def
write
(
self
,
s
):
CCodeWriter
.
write
(
self
,
s
)
self
.
annotation_buffer
.
write
(
s
)
def
mark_pos
(
self
,
pos
):
if
pos
is
not
None
:
CCodeWriter
.
mark_pos
(
self
,
pos
)
...
...
@@ -52,7 +52,7 @@ class AnnotationCCodeWriter(CCodeWriter):
def
annotate
(
self
,
pos
,
item
):
self
.
annotations
.
append
((
pos
,
item
))
def
save_annotation
(
self
,
source_filename
,
target_filename
):
self
.
mark_pos
(
None
)
f
=
Utils
.
open_source_file
(
source_filename
)
...
...
@@ -74,7 +74,7 @@ class AnnotationCCodeWriter(CCodeWriter):
all
.
append
(((
source_filename
,
pos
[
1
],
pos
[
2
]
+
size
),
end
))
else
:
all
.
append
((
pos
,
start
+
end
))
all
.
sort
()
all
.
reverse
()
for
pos
,
item
in
all
:
...
...
@@ -83,7 +83,7 @@ class AnnotationCCodeWriter(CCodeWriter):
col
+=
1
line
=
lines
[
line_no
]
lines
[
line_no
]
=
line
[:
col
]
+
item
+
line
[
col
:]
html_filename
=
os
.
path
.
splitext
(
target_filename
)[
0
]
+
".html"
f
=
codecs
.
open
(
html_filename
,
"w"
,
encoding
=
"UTF-8"
)
f
.
write
(
u'<html>
\n
'
)
...
...
@@ -130,14 +130,14 @@ function toggleDiv(id) {
c_file
=
Utils
.
decode_filename
(
os
.
path
.
basename
(
target_filename
))
f
.
write
(
u'<p>Raw output: <a href="
%
s">
%
s</a>
\n
'
%
(
c_file
,
c_file
))
k
=
0
py_c_api
=
re
.
compile
(
u'(Py[A-Z][a-z]+_[A-Z][a-z][A-Za-z_]+)
\
('
)
py_marco_api
=
re
.
compile
(
u'(Py[A-Z][a-z]+_[A-Z][A-Z_]+)
\
('
)
pyx_c_api
=
re
.
compile
(
u'(__Pyx_[A-Z][a-z_][A-Za-z_]+)
\
('
)
pyx_macro_api
=
re
.
compile
(
u'(__Pyx_[A-Z][A-Z_]+)
\
('
)
error_goto
=
re
.
compile
(
ur'((; *if .*)? \{__pyx_filename = .*goto __pyx_L\w+;\})'
)
refnanny
=
re
.
compile
(
u'(__Pyx_X?(GOT|GIVE)REF|__Pyx_RefNanny[A-Za-z]+)'
)
code_source_file
=
self
.
code
[
source_filename
]
for
line
in
lines
:
...
...
@@ -146,18 +146,18 @@ function toggleDiv(id) {
code
=
code_source_file
[
k
]
except
KeyError
:
code
=
''
code
=
code
.
replace
(
'<'
,
'<code><</code>'
)
code
,
py_c_api_calls
=
py_c_api
.
subn
(
ur"<span class='py_c_api'>\1</span>("
,
code
)
code
,
pyx_c_api_calls
=
pyx_c_api
.
subn
(
ur"<span class='pyx_c_api'>\1</span>("
,
code
)
code
,
py_macro_api_calls
=
py_marco_api
.
subn
(
ur"<span class='py_macro_api'>\1</span>("
,
code
)
code
,
pyx_macro_api_calls
=
pyx_macro_api
.
subn
(
ur"<span class='pyx_macro_api'>\1</span>("
,
code
)
code
,
refnanny_calls
=
refnanny
.
subn
(
ur"<span class='refnanny'>\1</span>"
,
code
)
code
,
error_goto_calls
=
error_goto
.
subn
(
ur"<span class='error_goto'>\1</span>"
,
code
)
code
=
code
.
replace
(
u"<span class='error_goto'>;"
,
u";<span class='error_goto'>"
)
score
=
5
*
py_c_api_calls
+
2
*
pyx_c_api_calls
+
py_macro_api_calls
+
pyx_macro_api_calls
-
refnanny_calls
color
=
u"FFFF
%02
x"
%
int
(
255
/
(
1
+
score
/
10.0
))
f
.
write
(
u"<pre class='line' style='background-color: #
%
s' onclick='toggleDiv(
\"
line
%
s
\"
)'>"
%
(
color
,
k
))
...
...
@@ -166,13 +166,13 @@ function toggleDiv(id) {
for
c
,
cc
,
html
in
special_chars
:
line
=
line
.
replace
(
cc
,
html
)
f
.
write
(
line
.
rstrip
())
f
.
write
(
u'</pre>
\n
'
)
code
=
re
.
sub
(
line_pos_comment
,
''
,
code
)
# inline annotations are redundant
f
.
write
(
u"<pre id='line
%
s' class='code' style='background-color: #
%
s'>
%
s</pre>"
%
(
k
,
color
,
code
))
f
.
write
(
u'</body></html>
\n
'
)
f
.
close
()
# TODO: make this cleaner
def
escape
(
raw_string
):
...
...
@@ -184,15 +184,15 @@ def escape(raw_string):
class
AnnotationItem
(
object
):
def
__init__
(
self
,
style
,
text
,
tag
=
""
,
size
=
0
):
self
.
style
=
style
self
.
text
=
text
self
.
tag
=
tag
self
.
size
=
size
def
start
(
self
):
return
u"<span class='tag
%
s' title='
%
s'>
%
s"
%
(
self
.
style
,
self
.
text
,
self
.
tag
)
def
end
(
self
):
return
self
.
size
,
u"</span>"
Cython/Compiler/AutoDocTransforms.py
View file @
f6762fad
...
...
@@ -101,7 +101,7 @@ class EmbedSignature(CythonTransform):
return
node
else
:
return
super
(
EmbedSignature
,
self
)
.
__call__
(
node
)
def
visit_ClassDefNode
(
self
,
node
):
oldname
=
self
.
class_name
oldclass
=
self
.
class_node
...
...
@@ -120,7 +120,7 @@ class EmbedSignature(CythonTransform):
def
visit_DefNode
(
self
,
node
):
if
not
self
.
current_directives
[
'embedsignature'
]:
return
node
is_constructor
=
False
hide_self
=
False
if
node
.
entry
.
is_special
:
...
...
Cython/Compiler/Buffer.py
View file @
f6762fad
...
...
@@ -57,12 +57,12 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
if
isinstance
(
node
,
ModuleNode
)
and
len
(
bufvars
)
>
0
:
# for now...note that pos is wrong
# for now...note that pos is wrong
raise
CompileError
(
node
.
pos
,
"Buffer vars not allowed in module scope"
)
for
entry
in
bufvars
:
if
entry
.
type
.
dtype
.
is_ptr
:
raise
CompileError
(
node
.
pos
,
"Buffers with pointer types not yet supported."
)
name
=
entry
.
name
buftype
=
entry
.
type
if
buftype
.
ndim
>
self
.
max_ndim
:
...
...
@@ -84,10 +84,10 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
if
entry
.
is_arg
:
result
.
used
=
True
return
result
stridevars
=
[
var
(
Naming
.
bufstride_prefix
,
i
,
"0"
)
for
i
in
range
(
entry
.
type
.
ndim
)]
shapevars
=
[
var
(
Naming
.
bufshape_prefix
,
i
,
"0"
)
for
i
in
range
(
entry
.
type
.
ndim
)]
shapevars
=
[
var
(
Naming
.
bufshape_prefix
,
i
,
"0"
)
for
i
in
range
(
entry
.
type
.
ndim
)]
mode
=
entry
.
type
.
mode
if
mode
==
'full'
:
suboffsetvars
=
[
var
(
Naming
.
bufsuboffset_prefix
,
i
,
"-1"
)
for
i
in
range
(
entry
.
type
.
ndim
)]
...
...
@@ -95,7 +95,7 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
suboffsetvars
=
None
entry
.
buffer_aux
=
Symtab
.
BufferAux
(
bufinfo
,
stridevars
,
shapevars
,
suboffsetvars
)
scope
.
buffer_entries
=
bufvars
self
.
scope
=
scope
...
...
@@ -138,9 +138,9 @@ def analyse_buffer_options(globalpos, env, posargs, dictargs, defaults=None, nee
"""
if
defaults
is
None
:
defaults
=
buffer_defaults
posargs
,
dictargs
=
Interpreter
.
interpret_compiletime_options
(
posargs
,
dictargs
,
type_env
=
env
,
type_args
=
(
0
,
'dtype'
))
if
len
(
posargs
)
>
buffer_positional_options_count
:
raise
CompileError
(
posargs
[
-
1
][
1
],
ERR_BUF_TOO_MANY
)
...
...
@@ -187,7 +187,7 @@ def analyse_buffer_options(globalpos, env, posargs, dictargs, defaults=None, nee
assert_bool
(
'cast'
)
return
options
#
# Code generation
...
...
@@ -209,7 +209,7 @@ def get_flags(buffer_aux, buffer_type):
assert
False
if
buffer_aux
.
writable_needed
:
flags
+=
"| PyBUF_WRITABLE"
return
flags
def
used_buffer_aux_vars
(
entry
):
buffer_aux
=
entry
.
buffer_aux
buffer_aux
.
buffer_info_var
.
used
=
True
...
...
@@ -258,10 +258,10 @@ def get_getbuffer_call(code, obj_cname, buffer_aux, buffer_type):
bufstruct
=
buffer_aux
.
buffer_info_var
.
cname
dtype_typeinfo
=
get_type_information_cname
(
code
,
buffer_type
.
dtype
)
return
(
"__Pyx_GetBufferAndValidate(&
%(bufstruct)
s, "
"(PyObject*)
%(obj_cname)
s, &
%(dtype_typeinfo)
s,
%(flags)
s,
%(ndim)
d, "
"
%(cast)
d, __pyx_stack)"
%
locals
())
"
%(cast)
d, __pyx_stack)"
%
locals
())
def
put_assign_to_buffer
(
lhs_cname
,
rhs_cname
,
buffer_aux
,
buffer_type
,
is_initialized
,
pos
,
code
):
...
...
@@ -272,7 +272,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type,
However, the assignment operation may throw an exception so that the reassignment
never happens.
Depending on the circumstances there are two possible outcomes:
- Old buffer released, new acquired, rhs assigned to lhs