Skip to content
Snippets Groups Projects

Choose backends

Merged Bitbucket Importer requested to merge bitbucket/merged-pr-54 into branch/default
60 files
+ 804
446
Compare changes
  • Side-by-side
  • Inline
Files
60
%% Cell type:code id: tags:
``` python
# Note that this has no effect on coverage :-(
from pathlib import Path
from time import sleep
from transonic.justintime import path_jit, modules, make_hex
from transonic.backends import backends
from transonic.config import backend_default
from transonic.justintime import modules, make_hex
from transonic.util import can_import_accelerator
from transonic import jit, Type
backend = backends[backend_default]
path_jit = backend.jit.path_base
compiler_importable = can_import_accelerator()
src = """T = Type(float, str)
@jit
def test(a: T):
return "hello", a"""
hex_src = make_hex(src)
module_name = "__ipython__" + hex_src
path_dir = path_jit / module_name
paths = path_dir.glob("*")
for path in paths:
path.unlink()
hex_src
T = Type(float, str)
@jit
def test(a: T):
return "hello", a
if compiler_importable:
key, mod = list(modules.items())[0]
cjit = mod.jit_functions["test"]
cjit.compiling
test(1.)
if compiler_importable:
cjit.compiling
# if pythran:
# assert key == module_name, (key, module_name)
if compiler_importable:
for _ in range(100):
test(1.)
sleep(0.1)
if not cjit.compiling:
break
if compiler_importable:
cjit.compiling
test(1.)
test("world")
```
%% Output
INFO  Schedule pythranization of file /home/pierre/.transonic/pythran/__jit__/__ipython__0ab66fcdc148f8e4aa8857fd83de3374/test.py
INFO  Schedule pythranization of file /home/pierre/.transonic/pythran/__jit__/__ipython__889772ca85990a579df84a832376093a/test.py
compile extension
('hello', 'world')
Loading