Alternative syntax for blocks with decorator and context manager

Issue #29 resolved
Pierre Augier created an issue

This proposition replaces issue #9...

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 write block("int: a, b; A: c, d, e")...

  • We could also support block signatures # pythran block (int: a, b; A: c, d, e) before with block(...):

  • We could also have cachedjit_block...

Technically, it is clear how we have to create the new functions from these code samples. This API is nicer than what we have now and better than what I proposed in issue #9. However, we cannot implement this without a clever analysis of the code (see issue #18)!

Comments (3)

  1. Log in to comment