thautwarm / diojit

Fully compatible CPython jit compiler. Optimising Dynamic, Interpreted, and Object-oriented(DIO) programs.
BSD 2-Clause "Simplified" License
117 stars 2 forks source link

providing builtin Closure type and constructor #8

Closed thautwarm closed 3 years ago

thautwarm commented 3 years ago

Proposal in #4 turns out to be difficult to implement due to

  1. Support #5 cannot be efficient in current framework because the use of non-constant tuple cannot get eliminated.

    As a consequence, self.f(*self.free, *args) will have to redundantly concat 2 tuples(self.free, args), because our IR is transformed from python bytecode and BUILD_TUPLE_UNPACK_WITH_CALL will produce the tuple concat semantics.

  2. User-defined types cannot hold typed members so far due to the obstacle to infer immutability and member types.

    class S:
       __slots__ = ['a', 'b']
       def __init__(self, a, b):
            self.a = a
            self.b = b

    It's difficult to make a parameteric type S[int, int] from python expression S(1, 2), due to side-effect powered __init__ and that the initialization is expressed with self.* = *.