PyGears difference between tuple and Tuple

Viewed 40

What is difference between tuple and Tuple in PyGears python framework? pygears.org doesn't mention anything about it.

1 Answers

tuple is Python syntax, while Tuple is PyGears syntax. When you want to send only one interface from your gear you have to use Tuple, while sending your data in many interfaces you use tuple.

Code example:

@gear
async def python_gear() -> (Uint[8], Uint[8]):
    yield (1, 2)

@gear
async def pygears_gear() -> Tuple[Uint[8], Uint[8]]:
    yield Tuple[1, 1]


pythons_res = []
pygears_res = []
@gear
def consumer():
    pythons = python_gear()
    pygears = pygears_gear()
    collect(ccat(*pythons), result=pythons_res)
    collect(pygears, result=pygears_res)


consumer()
sim()

Gearbox representation: enter image description here

Related