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
7548da6f
Commit
7548da6f
authored
Apr 02, 2011
by
Francesc Alted
Committed by
Dag Sverre Seljebotn
Apr 02, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed int_max and int_min because int and max are already optimal.
parent
72310bb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
14 deletions
+4
-14
docs/src/tutorial/numpy.rst
docs/src/tutorial/numpy.rst
+4
-14
No files found.
docs/src/tutorial/numpy.rst
View file @
7548da6f
...
...
@@ -110,16 +110,6 @@ compatibility. Here's :file:`convolve2.pyx`. *Read the comments!* ::
# every type in the numpy module there's a corresponding compile-time
# type with a _t-suffix.
ctypedef np.int_t DTYPE_t
# The builtin min and max functions works with Python objects, and are
# so very slow. So we create our own.
# - "cdef" declares a function which has much less overhead than a normal
# def function (but it is not Python-callable)
# - "inline" is passed on to the C compiler which may inline the functions
# - The C type "int" is chosen as return type and argument types
# - Cython allows some newer Python constructs like "a if x else b", but
# the resulting C file compiles with Python 2.3 through to Python 3.0 beta.
cdef inline int int_max(int a, int b): return a if a >= b else b
cdef inline int int_min(int a, int b): return a if a <= b else b
# "def" can type its arguments but not have a return type. The type of the
# arguments for a "def" function is checked at run-time when entering the
# function.
...
...
@@ -163,10 +153,10 @@ compatibility. Here's :file:`convolve2.pyx`. *Read the comments!* ::
cdef DTYPE_t value
for x in range(xmax):
for y in range(ymax):
s_from =
int_
max(smid - x, -smid)
s_to =
int_
min((xmax - x) - smid, smid + 1)
t_from =
int_
max(tmid - y, -tmid)
t_to =
int_
min((ymax - y) - tmid, tmid + 1)
s_from = max(smid - x, -smid)
s_to = min((xmax - x) - smid, smid + 1)
t_from = max(tmid - y, -tmid)
t_to = min((ymax - y) - tmid, tmid + 1)
value = 0
for s in range(s_from, s_to):
for t in range(t_from, t_to):
...
...
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