3 ms·
> Along those same lines, we will initially restrict the types that may be passed through channels to the following: > * None > * bytes > * str > * int > *
by simonw 4y ago
> Along those same lines, we will initially restrict the types that may be passed through channels to the following:
> * None
> * bytes
> * str
> * int
> * channels
> Limiting the initial shareable types is a practical matter, reducing the potential complexity of the initial implementation.
That's a really interesting detail - presumably channels can be passed so you can do callbacks ("reply on this other channel").
I wonder why floats aren't on that list? I know they're more complex than ints, but I would expect they would still end up with a relatively simple binary representation.
- galonk 4y agoI don’t know why floats aren’t included, but any float can be easily represented by an int with same bits, or a bytestring, using the struct module to convert between them, so there are clear workarounds.
- saagarjha 4y agoSounds like an oversight…
- nine_k 4y agoPassing channels over other channels used to be a reasonably standard trick in Go, IIRC.
- tylercrompton 4y agoFun fact, floats are easier than `int` because `float` has a predictable size.
- JoshTriplett 4y ago> That's a really interesting detail - presumably channels can be passed so you can do callbacks ("reply on this other channel"). Callbacks or notifications, yes. I use both patterns quite often.