Cython doesn't really have globals dictionary. http://cython.readthedocs.org/en/latest/src/userguide/limitations.html says:
"The globals() builtin returns the last Python callers globals, not the current function’s locals. This behavior should not be relied upon, as it will probably change in the future." So its somewhat by accident that this ends up injecting into the repl globals. Though at this point I don't really expect it to change in the future... Plain IPython version: sage: ip.ns_table['user_global']['foo'] = 'bar' sage: foo 'bar' sage: ip.ns_table['user_global'] is globals() True On Wednesday, March 25, 2015 at 5:40:40 PM UTC+1, Jeroen Demeyer wrote: > > Hello, > > I noticed that globals() does something different in Python and Cython. > In Cython, it allows to access the "top-level" globals, e.g. the globals > on the IPython command line. This is the reason that > > sage: _ = var('y') > sage: y > y > > works. However, this only works because the var() function is > implemented in Cython! Python's globals() are the globals of the module. > I am almost certain this is the source of #12446. > > So the question is: is it possible to access the top-level globals from > Python? Implementing stuff in Cython just because globals() behaves > differently looks very fragile to me. > > Jeroen. > -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.