Thanks, that seemed to do the trick. Since the goal was to get some working code into sage and not to make it blazingly fast I'll just use this solution.
Kind regards, Maarten Derickx On Jul 17, 7:01 am, Carl Witty <[email protected]> wrote: > On Fri, Jul 16, 2010 at 8:21 PM, koffie <[email protected]> wrote: > > Dear All, > > > I was writing some code for sage and ran into trouble. The code was > > working just fine when it was a standalone function. Then I tried to > > add it to a pyx file (sage/rings/fraction_field_element.pyx to be > > precise) and ran into trouble. Somewhere in the code I would like to > > use the command PolynomialRing, so I had to import it for else it > > wouldn't build. So I added the line > > > from sage.rings.polynomial.polynomial_ring_constructor import > > PolynomialRing > > > to the file. After having done this sage will build, but when running > > sage I get into trouble. I have no idea about how importing and stuff > > works in python/cython so if someone could help me with this I would > > be very glad. > > It looks like you've got a problem with a circular import, where file > A imports file B, which imports file C, ..., which imports file A. > > I don't know of a simple, systematic, efficient way to solve such > problems. The easy way is to move this line: > > from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing > > inside the function you just added. (For example, just put it on the > line before you use PolynomialRing.) The only problem with this > solution is that it adds a tiny bit of time (maybe a few microseconds) > to your function. If your function is very time-critical, you should > find another solution; but otherwise this should work fine. > > Carl -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
