pyteal icon indicating copy to clipboard operation
pyteal copied to clipboard

add method to encode tuple element

Open barnjamin opened this issue 2 years ago • 4 comments

I just want bytes, no need for other scratch vars or lambdas

diff from a program where i switched to this:

image

barnjamin avatar Dec 23 '22 22:12 barnjamin

I am still opinionated on this one tho, after some more thoughts. Maybe I am wrong.

This encode method applies to all ComputedType, so it also applies to ReturnedType which wraps up a computation returning something on stack. What if the encode called twice for a ReturnedType instance with a computation that has side effect? That would not be ideal.

ahangsu avatar Jan 04 '23 19:01 ahangsu

barnjamin can you please speak with Hang to elaborate his concerns regarding multiple instance requests of ReturnedType

bbroder-algo avatar Jan 12 '23 17:01 bbroder-algo

@ahangsu correctly notes that if someone were to call something like encode multiple times on a ReturnedValue the computation Expr would be run again.

However, this behavior is already present in the current release. While it isn't ideal I think it shouldn't be a show stopped for this pr. Perhaps another pr that improves how a ReturnedValue caches its computation (via scratch var or otherwise?) is warranted.

barnjamin avatar Jan 30 '23 17:01 barnjamin

I forgot about this one, assuming the conflict is resolved is it good to merge?

cc @ahangsu @bbroder-algo

barnjamin avatar Apr 11 '23 14:04 barnjamin