Ask Your Question

Revision history [back]

How to determine expression size before printing?

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 :)