Alternative syntax for blocks with decorator and context manager

Create issue
Issue #6 new
Pierre Augier created an issue

I'd like to support such things:

for functions:

from fluidpythran import with_blocks, block

@with_blocks
def func(arg: int):

    a = non_pythranizable(arg)

    with block():
        a: float
        return a + arg

and

@with_blocks
def func(arg: int):

    a = non_pythranizable(arg)

    with block():
        a: float
        tmp = a + arg

    return non_pythranizable(tmp)

for classes:

from fluidpythran import boost, with_blocks, block

@boost
class MyClass:

    attr0: int

    @with_blocks
    def func(self, arg: int):

        a = non_pythranizable(arg)

        with block():
            a: float
            tmp = a + arg + self.attr0

        return non_pythranizable(tmp)
  • We could also support block signatures # transonic block (int: a, b; A: c, d, e) in the block.

Comments (0)

  1. Log in to comment