[sage-support] Re: counting cusps for the principal congruence subgroup

2010-12-20 Thread John Cremona
You are right, and you can see the reason like this: sage: G = Gamma(5) sage: G.ncusps?? shows that the code is a one-liner return ZZ(len(self.cusps())) i.e. a complete set of cusps is computed (to see how, do G.cusps??), while for the other groups a formula is used, e.g. sage: G = Gamma0(5)

[sage-support] Re: Sage 4.6, openSUSE 11.3, sh: symbol lookup error: sh: undefined symbol: rl_filename_rewrite_hook [long]

2010-12-20 Thread Renan Birck Pinheiro
On 19 dez, 21:43, Renan Birck Pinheiro renan.ee.u...@gmail.com wrote: Hi, I'm using openSUSE 11.3 on x86_64. I try to install SAGE on it, and I downloaded the Ubuntu tarball (the Fedora tarball gives the same errors). [snip] Recompiling sage was the solution. Renan -- To post to this

[sage-support] PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Simon King
Dear sage-support, at #10496, David Roe gave me the advice to use PY_TYPE_CHECK rather than isinstance in Cython files. I did so. But actually I didn't know PY_TYPE_CHECK at all, and so I have a two questions: 1) Apparently there are several PY_... functions. Where can I read about them? 2)

Re: [sage-support] Re: Sage 4.6, openSUSE 11.3, sh: symbol lookup error: sh: undefined symbol: rl_filename_rewrite_hook [long]

2010-12-20 Thread Pedro Sanchez
On Mon, Dec 20, 2010 at 11:24 AM, Renan Birck Pinheiro renan.ee.u...@gmail.com wrote: On 19 dez, 21:43, Renan Birck Pinheiro renan.ee.u...@gmail.com wrote: Hi, I'm using openSUSE 11.3 on x86_64. I try to install SAGE on it, and I downloaded the Ubuntu tarball (the Fedora tarball gives the

[sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Jason Grout
On 12/20/10 1:42 PM, Simon King wrote: Dear sage-support, at #10496, David Roe gave me the advice to use PY_TYPE_CHECK rather than isinstance in Cython files. I did so. But actually I didn't know PY_TYPE_CHECK at all, and so I have a two questions: 1) Apparently there are several PY_...

[sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Volker Braun
PY_TYPE_CHECK is just a wrapper macro around PyObject_TypeCheck which dereferences and compares the object type fields. So that part should be insanely fast. sage: cython('cpdef t(x):\n for i in range(0,1000):\n PY_TYPE_CHECK(x,int)'); timeit(t(5000), repeat=100) 625 loops, best of 100:

[sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Volker Braun
Aha, with Jason's answer: Calling isinstance(x,int) on a python x is cheating, because Cython replaces it with PyInt_Check (no inheritance to check!). Calling isinstance on a C variable x goes through IS_INSTANCE which builds an unnecessary python boolean. -- To post to this group, send

Re: [sage-support] Re: Sage 4.6, openSUSE 11.3, sh: symbol lookup error: sh: undefined symbol: rl_filename_rewrite_hook [long]

2010-12-20 Thread Renan Birck Pinheiro
Em 20-12-2010 18:02, Pedro Sanchez escreveu: That problem is caused due to a libreadline library mismatch between those packaged with sage and those from the system. I got 4.6 today, and same problem arose. Solution worked once more again, delete sage's libreadline's thing. Hmm. I would never

Re: [sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Robert Bradshaw
The PY_TYPE_CHECK macro exists primarily because Cython didn't used to optimize isinstance. On Mon, Dec 20, 2010 at 12:34 PM, Volker Braun vbraun.n...@gmail.com wrote: PY_TYPE_CHECK is just a wrapper macro around PyObject_TypeCheck which dereferences and compares the object type fields. So that

Re: [sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Robert Bradshaw
On Mon, Dec 20, 2010 at 12:27 PM, Jason Grout jason-s...@creativetrax.com wrote: On 12/20/10 1:42 PM, Simon King wrote: Dear sage-support, at #10496, David Roe gave me the advice to use PY_TYPE_CHECK rather than isinstance in Cython files. I did so. But actually I didn't know PY_TYPE_CHECK

[sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Simon King
Dear Volker, dear Jason, thank you for your answers! So, I chose the wrong example isinstance(x,int). With other types to test, PY_TYPE_CHECK will be faster. @Volker But if you really write Cython code then you probably want to type the argument so that the compiler knows what x is. ...

[sage-support] Re: counting cusps for the principal congruence subgroup

2010-12-20 Thread rje
Thanks for the helpful response. The appropriate code for computing Gamma(n).ncusps() is n=self.level() if n=2: return[None,1,3][n] return ZZ(sum([moebius(d)*(n/d)^2/ZZ(2) for d in n.divisors()])) But can I impose on someone who knows the ticketing procedure to get this implemented?