Is there a simple way to convert
t = ((1,), (1, 2), (1, 2, 3), (1, 2, 3, 4), (1, 2, 3, 4, 5))
to the following recursive structure, where each following tuple is appended as an element of the prior tuple
(1, (1, 2, (1, 2, 3, (1, 2, 3, 4, (1, 2, 3, 4, 5)))))
What is the limit to this nesting? Can I have a 1000 or 10000 such nested tuples?
UPDATE:
It seems t
nesting is unlimited (tried with 10000 after setting recursion limit to 100).
On Window 7, Python 3.5) the recursion limit is around 300 at first, but can be lifted as (reference). This is not related to structure t
, but may be related to Python routine accessing nested levels of the resulting structure.
sys.getrecursionlimit() # display current recursion level
sys.setrecursionlimit(10000) # set recursion level to 1000