Hi

How about something like:

>>> def t1(*argv):
...     value = 0
...     for n in argv:
...         value *= 1_000
...         value += n
...     return value

>>> t1(123, 456, 789)
123456789

Similarly, for define t2 to use 1_000_000, t3 to use 1_000_000_000 and so
on, instead of 1_000. For really big numbers, you might want to use t10.

I think something like
>>> t10(
...     111_222_333_444_555_666_777_888_999_000,
...     111_222_333_444_555_666_777_888_999_000,
...     111_222_333_444_555_666_777_888_999_000,
... )
gives a nice representation of a 90 digit number.

If you're dealing with really big integers (say 1000 digits or more) then
you might be want to use https://pypi.org/project/gmpy2/, in  which case
you'll appreciate the extra flexibility provided by t10. (This would allow
t10 to return a gmpy integer, if import gmpy2 succeeds.)

Finally, perhaps really big numbers should be stored as data, rather than
placed in source code files. (For example, this would allow these large
pieces of data to be verified, via a secure hash.)

-- 
Jonathan
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JNYQCQBD5EMJPHZN34EJDCQOYJOFKTTF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to