Feature request: Optional contructor/wrapper

Hello guys,

I have a proposal for optional types. Currently there is no way to directly instantiate from optional types. You have to add the optional type the function signature in jit params. This is OK, but most of the time is a limitation because you are enforcing a single data type to the impelemtation.

My proposal is to add a new optinal constructor/wrapper which can return an optional type instance.

It can be something like this:

@njit
def foo(val):
    if val is not None:
        #do somthing with val
    else:
        #do nothing


val = typed.optional(None, types.int64)
foo(val)
val = typed.optional(3.24, types.float64)
foo(val)

In this way we can defer type inference until the last moment.

Optional constructor signature:

optional(initial_value or None, object_type)

Optional constructor should work with any data type supported by numba

@sklam suggested here https://github.com/numba/numba/issues/6063 that what I want can be emulated with an intrinsic…