loading large file

21 views
Skip to first unread message

Luis Finotti

unread,
Apr 2, 2021, 7:51:42 AMApr 2
to sage-support
I produced a very large text file (139MB) containing some input for Sage.

The problem is that when I try to load it, I get:


sage: load('matp11n2.sage')
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-2-92a91ed98544> in <module>
----> 1 load('matp11n2.sage')

~/src/sage-9.2/local/lib/python3.8/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persis
t.c:2558)()
   141
   142     if sage.repl.load.is_loadable_filename(filename):
--> 143         sage.repl.load.load(filename, globals())
   144         return
   145

~/src/sage-9.2/local/lib/python3.8/site-packages/sage/repl/load.py in load(filename, globals, attach)
   270                 add_attached_file(fpath)
   271             with open(fpath) as f:
--> 272                 exec(preparse_file(f.read()) + "\n", globals)
   273     elif ext == '.spyx' or ext == '.pyx':
   274         if attach:

RecursionError: maximum recursion depth exceeded during compilation

Any ideas on how I could load such file?

Luis Finotti

unread,
Apr 2, 2021, 3:02:38 PMApr 2
to sage-support
The solution I found was to increase the recursion limit: I did

sys.setrecursionlimit(4500)

It was enough for this.

John H Palmieri

unread,
Apr 2, 2021, 6:01:28 PMApr 2
to sage-support
Another option might have been to preparse separately (using "sage -preparse matp11n2.sage" at the shell prompt) and then load the resulting Python file.

  John

Luis Finotti

unread,
Apr 3, 2021, 7:45:40 AMApr 3
to sage-support
Thanks for the reply!

But that does not seem to work for me without increasing the recursion limit either...  But I did learn something new!
Reply all
Reply to author
Forward
0 new messages