I had a discussion regarding the use of python integers some time ago with 
Daniel Krenn. 

Basically, range and xrange produce Python integers, whereas srange and 
sxrange (from sage.misc.misc) produce
Integers. Also, when dealing with lists, len usually produces Python int's. 
(Maybe Daniel has some more common
pitfalls?)

In any case, after trying to change all range and xrange to srange and 
sxrange in dyck_word.py, the error
still occurred. It seems that directly after building sage, something 
happens such that the parameters 4,2 in the doctest

sage: TestSuite(DyckWords(4,2)).run()

are being treated as Python integers, rather than sage integers. Then, when 
the TestSuite comes to the test where
it checks that cardinality actually returns an Integer, it fails because 
the Python int's 4 and 2 cause the cardinality
to be a Python int, too.

Vincent has cured the symptom of these mysteriously occurring int's 
in http://trac.sagemath.org/ticket/18244 -- but the
nature of the original problem (i.e. that there are Python int's in the 
first place only with ./sage -bt and *not* with
./sage -t -- and this also not on all platforms) suggests that this might 
be something that runs deep.


Am Samstag, 18. April 2015 05:54:29 UTC+2 schrieb Darij Grinberg:
>
> This stuff is spooky... I've always been treating int and Integer as 
> interchangeable when coding for Sage. Maybe I've introduced several such 
> bugs.
>
> Can anyone explain in a noob-friendly way how an implementer should decide 
> between returning ints and Integers, when it is OK to treat them as 
> equivalent, and in what cases an explicit conversion into Integer needs to 
> be made? Thanks a lot!
>

-- 
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.

Reply via email to