On Sunday 15 September 2024 at 10:08:18 UTC-7 dim...@gmail.com wrote:

For me this code is rather unpredictable, as ipython and prompt_toolkit 
kick in 
and produce extra objects. 

For consistency (at least them the output values are reproducible) 
it looks better to experiment with Sage's python (./sage --python) 
for which the code needs to be adjusted, with "^" replaced by "**", and 
two lines added as the front: 

from sage.all import * 
var('x') 


Generally, to check if there's a leak one would look how object swell on 
the heap grows with iterations. That drowns out the constant overhead of 
the shell.
Or you can just wrap the whole measuring process in a function, so that it 
gets executed in an enclosed scope. There are generally some objects whose 
creation does scale with iteration and whose type is rather specific. You 
can grab one of those objects on the heap and look at its backreference 
graph. That generally gives a pretty good pointer to where the global 
references are held. It can actually be a fairly interesting challenge for 
someone with an interest in learning the nitty gritty details of the 
sagemath memory setup. It doesn't require brilliance; mostly persistence. 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/beacd365-e173-4ab9-a014-bb0fa89e2e54n%40googlegroups.com.

Reply via email to