#18083: Stop using old_style_globals
-------------------------------------+-------------------------------------
Reporter: jdemeyer | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.6
Component: cython | Resolution:
Keywords: | Merged in:
Authors: Jeroen Demeyer | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/jdemeyer/stop_using_old_style_globals|
9ccd889321d311903d4ab26449e6dd8154879aee
Dependencies: #12446, #18084 | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
Replying to [comment:12 jdemeyer]:
> That was exactly my question: how?
Logically the (very thin!) wrapper `cython` might be injected into the
same global scope as inject is written in.
Alternatively, once "inject" has been defined, we could inject it:
{{{
sage.misc.cython.inject = inject #we don't need cython_c anymore
}}}
ready for use there. Or one could access the dictionary there via
inject.func_globals (which wouldn't be so clean).
Admittedly, this is all not so much cleaner than what happens now. The
central "cleaner" principle is that there is a way of capturing a
"globals" dictionary: define a function there. That should be a portable
principle (accessing func_globals directly is probably not strictly
portable).
I'm not suggesting that we should absolutely implement it like this, but I
think it might be useful to design the underlying code in a way that it
*might* have been implemented in this way, simply to stay close to "the
python way" of doing things. I don't think the python way is sacred, but
since we're basing things on python, we should have good reasons every
time we do deviate from it. And I'm not so sure that for injection we do
have such a good reason.
One "python way" would be to define in, say, sage.misc.inject
{{{
def inject(...):
raise RuntimeError("injecting code in an environment where injection
isn't properly defined")
}}}
and then have the different interfaces/REPLs monkey patch an appropriate
"inject" into sage.misc.inject.inject.
I'm not so sure how clean monkey patching is and how robust this is
against `from sage.misc.inject import inject`, but at least it's an
entirely python solution.
--
Ticket URL: <http://trac.sagemath.org/ticket/18083#comment:13>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.