On Apr 1, 2008, at 1:23 PM, Gary Furnish wrote: > Wierd circular import issues can (should) be solved with circular > cdef imports. I think the easiest fix to crazy deps (group theory > on calculus) might be to do something alone the lines of > foo = None > def importcrazydeps(): > global foo > import sage.foo as localfoo > foo = localfoo > Then have sage.x.package import all package modules and sage.x.all > import sage.package and then run importcrazydeps() on any function.
Yep, I think such things should be handled manually rather than adding special behavior and caching to import functions in Cython. Note that of you do "cdef foo" then accessing foo in the global namespace will be a C lookup. One problem is that then we will have all kinds of importcrazydepsfor_x() functions at the end of sage.x.all, which will get longer and longer, until we have circular dependancies among these, etc. > Perhaps another approach would be in Cython with an import optional > foo (does not throw an exception on failure). -1. Then it throws an error later on? It has to check every time? I think the longterm solution is to reduce the number of "from foo import blah" (if you just do "import foo" and don't use foo, it will handle it just fine), reduce the number of unneeded imports (e.g. "from sage.rings.all import ZZ" which needlessly imports lots of other stuff than ZZ), and perhaps set up a hierarchy (e.g. decide which of groups or calculus should be imported first, and then if you need to go the other way do it via "late imports" of without the "from" keyword. Sometimes it amazes me that the whole library manages to load at all. > On Tue, Apr 1, 2008 at 1:41 PM, Carl Witty <[EMAIL PROTECTED]> > wrote: > > On Apr 1, 11:23 am, Robert Bradshaw <[EMAIL PROTECTED]> > wrote: > > On Apr 1, 2008, at 10:45 AM, Nick Alexander wrote: > > > > > On 1-Apr-08, at 10:36 AM, Gary Furnish wrote: > > > > >> Right now pulling in group theory may end up pulling in calculus. > > >> There are similar issues all over with really tight coupling > > >> between subsystems. It ought to be possible to use group theory > > >> (maybe without a feature or two) without calculus and vice versa. > > > > > This isn't really a global namespace pollution issue, but it is a > > > concern. One way to deal with this is to make (more) imports > > > function or class local. I'm not sure if there are performance > > > penalties for this, especially in Cython. Can anyone say? > > > > Importing locally takes time, even if just to discover the cached > > import if it has already been done once. This is independent of > > whether or not the file is in Cython (though the relative overhead > > may be much greater for a Cythonized function). > > For instance, see https://bugs.launchpad.net/cython/+bug/155076, where > I measure the cost of a local import as around 2 microseconds. > > > The order in which things are imported is really, really crazy right > > now, as anyone trying to hunt down an (easy to trigger) circular > > references can attest to. It would be great if this could be cleaned > > up, both for developing Sage and for making things more modular so > > other projects can benefit from them. > > Yes, this would be great! > > It seems like it would be very difficult to fix, though. > > Carl > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---