arogozhnikov / einops

Flexible and powerful tensor operations for readable and reliable code (for pytorch, jax, TF and others)
https://einops.rocks
MIT License
8.54k stars 352 forks source link

allow tuples alongside lists for reduce, rearrange, repeat #306

Closed tran-khoa closed 10 months ago

arogozhnikov commented 10 months ago

allowing tuples is a bad idea.

Safety: tuples are sometimes returned from e.g. torch methods and user may pass those without checking. Semantically, list is correct as enumerates similar items. From code readability, using rearrange([x, y], ...) is also preferred to rearrange((x, y), ...)

Finally, rearrange([*x], ...) takes only 3 additional symbols