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
0dffecfa
Commit
0dffecfa
authored
Dec 14, 2021
by
Matus Valo
Committed by
GitHub
Dec 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs: Migrate profiling tutorial to pure Python (GH-4311)
parent
b2fac63f
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
213 additions
and
63 deletions
+213
-63
docs/examples/tutorial/profiling_tutorial/calc_pi.py
docs/examples/tutorial/profiling_tutorial/calc_pi.py
+0
-2
docs/examples/tutorial/profiling_tutorial/calc_pi_2.py
docs/examples/tutorial/profiling_tutorial/calc_pi_2.py
+12
-0
docs/examples/tutorial/profiling_tutorial/calc_pi_2.pyx
docs/examples/tutorial/profiling_tutorial/calc_pi_2.pyx
+0
-2
docs/examples/tutorial/profiling_tutorial/calc_pi_3.py
docs/examples/tutorial/profiling_tutorial/calc_pi_3.py
+15
-0
docs/examples/tutorial/profiling_tutorial/calc_pi_3.pyx
docs/examples/tutorial/profiling_tutorial/calc_pi_3.pyx
+3
-2
docs/examples/tutorial/profiling_tutorial/calc_pi_4.py
docs/examples/tutorial/profiling_tutorial/calc_pi_4.py
+17
-0
docs/examples/tutorial/profiling_tutorial/calc_pi_4.pyx
docs/examples/tutorial/profiling_tutorial/calc_pi_4.pyx
+4
-3
docs/examples/tutorial/profiling_tutorial/often_called.py
docs/examples/tutorial/profiling_tutorial/often_called.py
+5
-0
docs/examples/tutorial/profiling_tutorial/profile.py
docs/examples/tutorial/profiling_tutorial/profile.py
+0
-2
docs/examples/tutorial/profiling_tutorial/profile_2.py
docs/examples/tutorial/profiling_tutorial/profile_2.py
+0
-2
docs/src/tutorial/profiling_tutorial.rst
docs/src/tutorial/profiling_tutorial.rst
+157
-50
No files found.
docs/examples/tutorial/profiling_tutorial/calc_pi.py
View file @
0dffecfa
# calc_pi.py
def
recip_square
(
i
):
return
1.
/
i
**
2
...
...
docs/examples/tutorial/profiling_tutorial/calc_pi_2.py
0 → 100644
View file @
0dffecfa
# cython: profile=True
import
cython
def
recip_square
(
i
:
cython
.
longlong
):
return
1.
/
i
**
2
def
approx_pi
(
n
:
cython
.
int
=
10000000
):
val
:
cython
.
double
=
0.
k
:
cython
.
int
for
k
in
range
(
1
,
n
+
1
):
val
+=
recip_square
(
k
)
return
(
6
*
val
)
**
.
5
docs/examples/tutorial/profiling_tutorial/calc_pi_2.pyx
View file @
0dffecfa
# cython: profile=True
# calc_pi.pyx
def
recip_square
(
int
i
):
return
1.
/
i
**
2
...
...
docs/examples/tutorial/profiling_tutorial/calc_pi_3.py
0 → 100644
View file @
0dffecfa
# cython: profile=True
import
cython
@
cython
.
cfunc
@
cython
.
inline
@
cython
.
exceptval
(
-
1.0
)
def
recip_square
(
i
:
cython
.
longlong
)
->
cython
.
double
:
return
1.
/
(
i
*
i
)
def
approx_pi
(
n
:
cython
.
int
=
10000000
):
val
:
cython
.
double
=
0.
k
:
cython
.
int
for
k
in
range
(
1
,
n
+
1
):
val
+=
recip_square
(
k
)
return
(
6
*
val
)
**
.
5
docs/examples/tutorial/profiling_tutorial/calc_pi_3.pyx
View file @
0dffecfa
# cython: profile=True
# calc_pi.pyx
cdef
inline
double
recip_square
(
int
i
)
except
-
1.0
:
cdef
inline
double
recip_square
(
long
long
i
)
except
-
1.0
:
return
1.
/
(
i
*
i
)
def
approx_pi
(
int
n
=
10000000
):
...
...
docs/examples/tutorial/profiling_tutorial/calc_pi_4.py
0 → 100644
View file @
0dffecfa
# cython: profile=True
import
cython
@
cython
.
profile
(
False
)
@
cython
.
cfunc
@
cython
.
inline
@
cython
.
exceptval
(
-
1.0
)
def
recip_square
(
i
:
cython
.
longlong
)
->
float
:
return
1.
/
(
i
*
i
)
def
approx_pi
(
n
:
cython
.
int
=
10000000
):
val
:
cython
.
double
=
0.
k
:
cython
.
int
for
k
in
range
(
1
,
n
+
1
):
val
+=
recip_square
(
k
)
return
(
6
*
val
)
**
.
5
docs/examples/tutorial/profiling_tutorial/calc_pi_4.pyx
View file @
0dffecfa
# cython: profile=True
# calc_pi.pyx
cimport
cython
@
cython
.
profile
(
False
)
cdef
inline
double
recip_square
(
int
i
)
except
-
1.0
:
cdef
inline
double
recip_square
(
long
long
i
)
except
-
1.0
:
return
1.
/
(
i
*
i
)
def
approx_pi
(
int
n
=
10000000
):
...
...
docs/examples/tutorial/profiling_tutorial/often_called.py
0 → 100644
View file @
0dffecfa
import
cython
@
cython
.
profile
(
False
)
def
my_often_called_function
():
pass
docs/examples/tutorial/profiling_tutorial/profile.py
View file @
0dffecfa
# profile.py
import
pstats
,
cProfile
import
calc_pi
...
...
docs/examples/tutorial/profiling_tutorial/profile_2.py
View file @
0dffecfa
# profile.py
import
pstats
,
cProfile
import
pyximport
...
...
docs/src/tutorial/profiling_tutorial.rst
View file @
0dffecfa
This diff is collapsed.
Click to expand it.
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