Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/src/sage_setup/cython_options.py
4052 views
1
import sys
2
3
4
def compiler_directives(profile: bool):
5
"""
6
Return a list of Cython directives used for compilation.
7
"""
8
return dict(
9
# Do not generate __reduce__ methods
10
auto_pickle=False,
11
# Do not create __test__ dictionary automatically from docstrings
12
autotestdict=False,
13
# When enabled, functions will be bound to an instance when looked up as a
14
# class attribute (hence the name) and will emulate the attributes of
15
# Python functions, including introspections like argument names and
16
# annotations
17
binding=True,
18
c_api_binop_methods=True,
19
# Do not check for division by 0 (this is about 35% quicker than with check)
20
cdivision=True,
21
cpow=True,
22
# Embed a textual copy of the call signature in the docstring (to support tools like IPython)
23
embedsignature=True,
24
fast_getattr=True,
25
# Use Python 3 (including source code semantics) for module compilation
26
language_level="3",
27
legacy_implicit_noexcept=True,
28
# Enable support for late includes (make declarations in Cython code available to C include files)
29
preliminary_late_includes_cy28=True,
30
# Add hooks for Python profilers into the compiled C code
31
profile=profile,
32
)
33
34
35
def compile_time_env_variables():
36
"""
37
Return a list of environmental variables used for compilation.
38
"""
39
return dict(
40
PY_PLATFORM=sys.platform,
41
# The following two constants are here only for backwards compatibility of user packages
42
PY_VERSION_HEX=sys.hexversion,
43
PY_MAJOR_VERSION=sys.version_info[0]
44
)
45
46