thautwarm / restrain-jit

The first and yet the only CPython compatible Python JIT, over the world.(julia backend: https://github.com/thautwarm/RestrainJIT.jl)
MIT License
107 stars 6 forks source link

Introducing nopython literals. #5

Open thautwarm opened 5 years ago

thautwarm commented 5 years ago

Currently we found speeding up the operations on original Python objects are difficult. Actually at this stage there's a great performance loss when using restrain-jit with python objects.

I'm considering about introducing following syntax to support creating native literals:

from restrain_jit.literals import L # make checkers compat with typing
def f(x):
     vec = L@[1, 2, 3] # Julia's Vector{Int}
     tp = L@(1, 2, 3) # Julia's Tuple{Int, Int, Int}
     d = L@{1:2}  # julia's OrderedDict{Int, Int}
     s = L@{1, 2} # julia's OrderedSet{Int}
thautwarm commented 5 years ago

Also, to specify the type of some polymorphic literals:

from restrain_jit.literals import T
def f(x):
    a = T[np.int64](1) # Julia's Int64
    b = T[np.uint32](1) # Julia's UInt32