User referenceΒΆ
User reference for the Pythas package.
The Compiler
instance (imported as compiler
) and SourceModule
constructor are the major constituents of the API. Everything else, all the necessary setup, is executed automatically at import time.
CompilerΒΆ
-
class
pythas.compiler.
Compiler
(flags=('-O2')) Interface for the compiler used to create shared libraries.
- Parameters
flags (Tuple[str]) β Compile time flags to append. Default value is using the β-O2β flag.
-
GHC_VERSION
Version number string of the used GHC instance.
- Type
str
-
flags
Flags for compiler.
- Type
tuple(str)
-
stack_usage
Enable the usage of stack for compilation. Will default to False if stack is not available.
- Type
bool
-
add_flag
(flag) Adds a flag to flags.
- Parameters
flag (str) β A valid compile time flag.
-
compile
(filename) Creates an FFI file, compiles and links it against the Python runtime.
- Parameters
filename (str) β Pathlike object to a Haskell source file.
- Returns
ffi_libs β List of tuples of linked libraries and their respective parsed infos.
- Return type
[(ctypes.CDLL, pythas.parser.data.ParseInfo)]
-
copy
() Creates a new instance of
Compiler
from an existing one. Flags andstack_usage
will be consistent.- Returns
new β The new Compiler instance.
- Return type
-
remove_flag
(flag) Removes a flag from flags.
- Parameters
flag (str) β A flag contained within flags.
SourceModuleΒΆ
-
class
pythas.compiler.
SourceModule
(code, compiler=None, use_stack=True, flags=('-O2')) Module created from inline Haskell source code. Will instantiate its own instance of
Compiler
unless an alternative is provided. Other settings will not be permanently made in the compiler instance.- Parameters