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
10577403
Commit
10577403
authored
Apr 30, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
merge in cython-unstable
parents
6f637eff
5b8c5b09
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
73 additions
and
18 deletions
+73
-18
Cython/Compiler/ControlFlow.py
Cython/Compiler/ControlFlow.py
+7
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+5
-0
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+24
-0
Cython/Compiler/Tests/TestParseTreeTransforms.py
Cython/Compiler/Tests/TestParseTreeTransforms.py
+1
-1
Cython/Plex/Lexicons.py
Cython/Plex/Lexicons.py
+6
-3
Cython/Shadow.py
Cython/Shadow.py
+7
-4
Cython/Utils.py
Cython/Utils.py
+6
-6
Cython/__init__.py
Cython/__init__.py
+1
-1
setup.py
setup.py
+14
-0
tests/run/consts.pyx
tests/run/consts.pyx
+2
-2
No files found.
Cython/Compiler/ControlFlow.py
View file @
10577403
...
...
@@ -13,7 +13,13 @@ import bisect, sys
# redesigned. It doesn't take return, raise, continue, or break into
# account.
_END_POS
=
((
unichr
(
sys
.
maxunicode
)
*
10
),())
from
Cython.Compiler.Scanning
import
StringSourceDescriptor
try
:
_END_POS
=
(
StringSourceDescriptor
(
unichr
(
sys
.
maxunicode
)
*
10
,
''
),
sys
.
maxint
,
sys
.
maxint
)
except
AttributeError
:
# Py3
_END_POS
=
(
StringSourceDescriptor
(
unichr
(
sys
.
maxunicode
)
*
10
,
''
),
sys
.
maxsize
,
sys
.
maxsize
)
class
ControlFlow
(
object
):
...
...
Cython/Compiler/Optimize.py
View file @
10577403
...
...
@@ -13,6 +13,11 @@ from StringEncoding import EncodedString
from
Errors
import
error
from
ParseTreeTransforms
import
SkipDeclarations
try
:
reduce
except
NameError
:
from
functools
import
reduce
#def unwrap_node(node):
# while isinstance(node, ExprNodes.PersistentNode):
# node = node.arg
...
...
Cython/Compiler/Scanning.py
View file @
10577403
...
...
@@ -232,6 +232,7 @@ class SourceDescriptor(object):
A SourceDescriptor should be considered immutable.
"""
_escaped_description
=
None
_cmp_name
=
''
def
__str__
(
self
):
assert
False
# To catch all places where a descriptor is used directly as a filename
...
...
@@ -241,6 +242,27 @@ class SourceDescriptor(object):
self
.
get_description
().
encode
(
'ASCII'
,
'replace'
).
decode
(
"ASCII"
)
return
self
.
_escaped_description
def
__gt__
(
self
,
other
):
# this is only used to provide some sort of order
try
:
return
self
.
_cmp_name
>
other
.
_cmp_name
except
AttributeError
:
return
False
def
__lt__
(
self
,
other
):
# this is only used to provide some sort of order
try
:
return
self
.
_cmp_name
<
other
.
_cmp_name
except
AttributeError
:
return
False
def
__le__
(
self
,
other
):
# this is only used to provide some sort of order
try
:
return
self
.
_cmp_name
<=
other
.
_cmp_name
except
AttributeError
:
return
False
class
FileSourceDescriptor
(
SourceDescriptor
):
"""
Represents a code source. A code source is a more generic abstraction
...
...
@@ -251,6 +273,7 @@ class FileSourceDescriptor(SourceDescriptor):
"""
def
__init__
(
self
,
filename
):
self
.
filename
=
filename
self
.
_cmp_name
=
filename
def
get_lines
(
self
):
return
Utils
.
open_source_file
(
self
.
filename
)
...
...
@@ -278,6 +301,7 @@ class StringSourceDescriptor(SourceDescriptor):
def
__init__
(
self
,
name
,
code
):
self
.
name
=
name
self
.
codelines
=
[
x
+
"
\
n
"
for
x
in
code
.
split
(
"
\
n
"
)]
self
.
_cmp_name
=
name
def
get_lines
(
self
):
return
self
.
codelines
...
...
Cython/Compiler/Tests/TestParseTreeTransforms.py
View file @
10577403
Cython/Plex/Lexicons.py
View file @
10577403
...
...
@@ -164,10 +164,13 @@ class Lexicon(object):
# token_number, "Pattern can match 0 input symbols")
if
isinstance
(
action_spec
,
Actions
.
Action
):
action
=
action_spec
elif
callable
(
action_spec
):
action
=
Actions
.
Call
(
action_spec
)
else
:
try
:
action_spec
.
__call__
except
AttributeError
:
action
=
Actions
.
Return
(
action_spec
)
else
:
action
=
Actions
.
Call
(
action_spec
)
final_state
=
machine
.
new_state
()
re
.
build_machine
(
machine
,
initial_state
,
final_state
,
match_bol
=
1
,
nocase
=
0
)
...
...
Cython/Shadow.py
View file @
10577403
...
...
@@ -23,7 +23,7 @@ def cmod(a, b):
# Emulated language constructs
def
cast
(
type
,
arg
):
if
callable
(
type
):
if
hasattr
(
type
,
'__call__'
):
return
type
(
arg
)
else
:
return
arg
...
...
@@ -35,7 +35,7 @@ def address(arg):
return
pointer
(
type
(
arg
))([
arg
])
def
declare
(
type
=
None
,
value
=
None
,
**
kwds
):
if
type
and
callable
(
type
):
if
type
is
not
None
and
hasattr
(
type
,
'__call__'
):
if
value
:
return
type
(
value
)
else
:
...
...
@@ -150,9 +150,12 @@ class typedef(CythonType):
py_int
=
int
py_long
=
long
py_float
=
float
py_int
=
int
try
:
py_long
=
long
except
NameError
:
# Py3
py_long
=
int
# Predefined types
...
...
Cython/Utils.py
View file @
10577403
...
...
@@ -110,18 +110,18 @@ class UtilityCode(object):
def
write_init_code
(
self
,
writer
,
pos
):
if
not
self
.
init
:
return
if
callable
(
self
.
init
):
self
.
init
(
writer
,
pos
)
else
:
if
isinstance
(
self
.
init
,
basestring
):
writer
.
put
(
self
.
init
)
else
:
self
.
init
(
writer
,
pos
)
def
write_cleanup_code
(
self
,
writer
,
pos
):
if
not
self
.
cleanup
:
return
if
callable
(
self
.
cleanup
):
self
.
cleanup
(
writer
,
pos
)
else
:
if
isinstance
(
self
.
cleanup
,
basestring
):
writer
.
put
(
self
.
cleanup
)
else
:
self
.
cleanup
(
writer
,
pos
)
def
specialize
(
self
,
pyrex_type
=
None
,
**
data
):
# Dicts aren't hashable...
...
...
Cython/__init__.py
View file @
10577403
# Void cython.* directives (for case insensitive operating systems).
from
Shadow
import
*
from
Cython.
Shadow
import
*
setup.py
View file @
10577403
...
...
@@ -10,6 +10,18 @@ if sys.platform == "win32":
setup_args
=
{}
if
sys
.
version_info
[
0
]
>=
3
:
import
lib2to3.refactor
from
distutils.command.build_py
\
import
build_py_2to3
as
build_py
# need to convert sources to Py3 on installation
fixers
=
[
fix
for
fix
in
lib2to3
.
refactor
.
get_fixers_from_package
(
"lib2to3.fixes"
)
if
fix
.
split
(
'fix_'
)[
-
1
]
not
in
(
'next'
,)
]
build_py
.
fixer_names
=
fixers
setup_args
[
'cmdclass'
]
=
{
"build_py"
:
build_py
}
if
sys
.
version_info
<
(
2
,
4
):
import
glob
cython_dir
=
os
.
path
.
join
(
get_python_lib
(
prefix
=
''
),
'Cython'
)
...
...
@@ -35,6 +47,8 @@ else:
scripts
=
[
"cython.py"
]
try
:
if
sys
.
version_info
[
0
]
>=
3
:
raise
ValueError
sys
.
argv
.
remove
(
"--no-cython-compile"
)
except
ValueError
:
try
:
...
...
tests/run/consts.pyx
View file @
10577403
...
...
@@ -16,7 +16,7 @@ True
True
>>> mul() == 1*60*1000
True
>>> arithm() == 9*2+3*8/6-10
>>> arithm() == 9*2+3*8/
/
6-10
True
>>> parameters() == _func(-1 -2, - (-3+4), 1*2*3)
True
...
...
@@ -52,7 +52,7 @@ def mul():
return
1
*
60
*
1000
def
arithm
():
return
9
*
2
+
3
*
8
/
6
-
10
return
9
*
2
+
3
*
8
/
/
6
-
10
def
parameters
():
return
_func
(
-
1
-
2
,
-
(
-
3
+
4
),
1
*
2
*
3
)
...
...
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