Wouldn't this allocate wasteful amounts of RAM unnecessarily for every step in a calculation?

not if it gets optimized out