How to determine expression size before printing?

asked 2023-03-18 19:52:26 +0200

Hello,

doing:

expression = 10^10^7*x

takes less than a second

but doing:

len(str(expression))

takes a lot of time.

I would like to quickly check the size of the output expression and if too large, then throw some exception. Is there a fast way to do it?

If

expression = 10^10^7

I could use

expression.ndigits()

but if it contains pi, x etc I cannot come up with any other solution than len(str(..)) which is time consuming.

Thanks :)

edit retag flag offensive close merge delete