+ 2

How to change recursion limit in skuplt python?

Skuplt is web python.I use it on SL to show my turtle codes .(Thanks to Burey ). But how can I change recursion limit on it.I have created a fractal code so I need recursion.The error i get is : ExternalError:RangeError:Maximum call stack size exceeded . https://code.sololearn.com/WFuyfuqpQ7bb/?ref=app

28th May 2019, 11:10 AM
Saksham Jain
Saksham Jain - avatar
13 Answers
+ 7
It is a guard against a stack overflow, yes. Python (or rather, the CPython implementation) doesn't optimize tail recursion, and unbridled recursion causes stack overflows. You can change the recursion limit with sys.setrecursionlimit, but doing so is dangerous -- the standard limit is a little conservative, but Python stackframes can be quite big. Python isn't a functional language and tail recursion is not a particularly efficient technique. Rewriting the algorithm iteratively, if possible, is generally a better idea. source: stackoverflow
30th May 2019, 12:09 AM
BroFar
BroFar - avatar
+ 6
Without seeing the code itself the problem could be that a new event comes in while your event hander is still processing the previous event, so the event handler gets called from inside the event handler which looks like a recursion! The fix is to disable the event binding while inside the event handler:
29th May 2019, 1:18 PM
BroFar
BroFar - avatar
+ 6
*{ margin:0px; left:0px; } in the css https://code.sololearn.com/W0QhCFfEBi85/?ref=app
30th May 2019, 3:00 PM
BroFar
BroFar - avatar
+ 6
Swapnil More / Saksham Jain I kept running into the same issue even after I shrunk it and tried to move it further to the left margin... as to the consuming of the stack. https://code.sololearn.com/WvoKWC1F29nI/?ref=app
30th May 2019, 8:08 PM
BroFar
BroFar - avatar
+ 4
Saksham Jain try using an if else to restore caesars values before line line 21 or 22 I would say to try caesara.reset_orig() caesara.reset_defaults() But I'm not sure that really would work as you have 3 values... And they would reset prematurely
29th May 2019, 10:07 PM
BroFar
BroFar - avatar
+ 3
BroFarOps I don't get the reset_orig() and reset_defaults thing? And also python recursion limit is platform dependent so that code works well on my PC (even on Sololearn)
30th May 2019, 4:46 AM
Saksham Jain
Saksham Jain - avatar
+ 3
Swapnil More did you created 4 turtles? Now how can I change the location of square?I want it to be a bit up and a bit left
30th May 2019, 2:41 PM
Saksham Jain
Saksham Jain - avatar
+ 3
https://code.sololearn.com/WhmXtVn3aJgE/?ref=app Not working BroFarOps And Swapnil More if I add just one more go-to command it gets out of range as you can see..
30th May 2019, 3:25 PM
Saksham Jain
Saksham Jain - avatar
+ 2
BroFarOps Swapnil More Can you guys help?
29th May 2019, 1:11 PM
Saksham Jain
Saksham Jain - avatar
+ 1
BroFarOps I have now inserted the code and I am not using any event handlers .
29th May 2019, 2:41 PM
Saksham Jain
Saksham Jain - avatar
+ 1
Saksham Jain that's the reason I removed those coordinates because changing the position of turtle was consuming the stack
30th May 2019, 3:49 PM
...
+ 1
Swapnil More /BroFarOps but that works on square but suppose I want to generalize carsaro square to n polygon caesaro then this way won't work...
31st May 2019, 1:18 PM
Saksham Jain
Saksham Jain - avatar