Skip to content

Precedence of with statement versus njit kwargs #318

Closed
@hameerabbasi

Description

@hameerabbasi

There is one side-effect of with statements: Their effects propagate down the call stack, even into library code. Consider the following code:

# In library.py
@njit(parallel=False)
def library_func(...):
    ...

# In user.py
with dppl.device_context(gpu):
    ...
    library_func(...)
    ...

In this case, if the with statement is preferred, the library loses control of what's executed inside library_func . Raising an error is okay, IMO, but for this reason, we shouldn't prefer what the with statement says.

Personally, I'd be okay with changing the default value of parallel to parallel=unspecified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions