DEV Community

Discussion on: TIL: Python Recursion Limit When Accessing Elements in Recursive List

Collapse
 
gkucmierz profile image
Grzegorz Kućmierz • Edited

Interesting!

const arr = [1];
arr.push(arr);

console.log(arr);

It looks like in #JavaScript it works with 8925 but not with 8926

Collapse
 
fronkan profile image
Fredrik Sjöstrand

Interesting! Also a fun fact is that I tried out a similar method in Python using exec and sting multiply.

exec("my_list" + "[1]"*10)

But this actually caused it to hit the recursion error earlier than using the method I used in the post. Although it still went deeper than the limit if I remember correctly. Fyi, to not get board I used string multiply and good ol' copy-paste.