Replies: 2 comments 1 reply
-
|
Guppy does not support union types in the way that python does, and does not intend to. The closest planned feature is Sum/Enum types, which are full structured unions. More in the near term though, Protocols are in progress and would also be a good way of implementing your generic functionality. Your In the meantime - just using array and passing in |
Beta Was this translation helpful? Give feedback.
-
|
So it sounds like I need to just wait for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a suite of helper functions which I want to accept both array and frozenarray arguments, as in
Union-ing types in this way throws a Guppy error.
I can hack my way to the desired functionality by writing copies of the function and then using function overloading to accept different input types, but this quickly grows into quite a mess.
Is there a suitable generic type I can use? Some other way to do this cleanly?
Another thought: I suppose if
varis afrozenarray, I could always pass it asfunc(var.mutable_copy()), ...), but that seems to go against the point of havingfrozenarrays(?)Beta Was this translation helpful? Give feedback.
All reactions