Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# print(test_repeat_append_jit())
# print(test_repeat_append_jit_foreach())
#
# for e in (test_repeat_append_jit_foreach.__func_info__.r_codeinfo.instrs):
# print(e)
# show_instrs(test_repeat_append_jit_foreach.__func_info__.r_codeinfo.instrs)
#
# %timeit test_repeat_append_jit()
# %timeit test_repeat_append_nojit()
# %timeit test_repeat_append_jit_foreach()
from julia import Main
tt = Main.eval("""
function tt()
x = []
for i in 0:9999
push!(x, i)
end
x
end
""")
tt()
import timeit
print(timeit.timeit("tt()", globals=dict(tt=tt), number=1000))
print(timeit.timeit(
"tt()", globals=dict(tt=test_repeat_append_nojit), number=1000))
# set package
from julia import Main
Main.eval("using AdversarialPrediction")
Main.eval("import AdversarialPrediction: define, constraint")
class Metric:
def __init__(self, metric_str):
self.metric_str = metric_str
# check name and args
name_args = metric_str.split("@metric")[1].strip().split("\n")[0].split()
self.name = name_args[0]
self.args = name_args[1:]
# run on julia
Main.eval(metric_str)
def initialize(self, *args):
init_str = self.name + "(" + ( ", ".join(map(str, args)) ) + ")"
# set package
from julia import Main
Main.eval("using AdversarialPrediction")
Main.eval("import AdversarialPrediction: define, constraint")
class Metric:
def __init__(self, metric_str):
self.metric_str = metric_str
# check name and args
name_args = metric_str.split("@metric")[1].strip().split("\n")[0].split()
self.name = name_args[0]
self.args = name_args[1:]
# run on julia
Main.eval(metric_str)
def initialize(self, *args):
init_str = self.name + "(" + ( ", ".join(map(str, args)) ) + ")"
# construct metric object
def __init__(self, metric_str):
self.metric_str = metric_str
# check name and args
name_args = metric_str.split("@metric")[1].strip().split("\n")[0].split()
self.name = name_args[0]
self.args = name_args[1:]
# run on julia
Main.eval(metric_str)
def initialize(self, *args):
init_str = self.name + "(" + ( ", ".join(map(str, args)) ) + ")"
# construct metric object
self.pm = Main.eval(init_str)