Re: [sage-devel] "is" and python integers

2010-07-28 Thread William Stein
On Wednesday, July 28, 2010, Carl Witty wrote: > On Wed, Jul 28, 2010 at 7:07 PM, William Stein wrote: >> On Wednesday, July 28, 2010, kcrisman wrote: >>> But for True and False, we would rather have >>> >>> if n is True: >>> >>> not >>> >>> if n==True: >>> >>> correct?  I've seen that cause som

Re: [sage-devel] "is" and python integers

2010-07-28 Thread Carl Witty
On Wed, Jul 28, 2010 at 7:07 PM, William Stein wrote: > On Wednesday, July 28, 2010, kcrisman wrote: >> But for True and False, we would rather have >> >> if n is True: >> >> not >> >> if n==True: >> >> correct?  I've seen that cause some problems in code I've reviewed, >> where things that shoul

Re: [sage-devel] "is" and python integers

2010-07-28 Thread William Stein
On Wednesday, July 28, 2010, kcrisman wrote: > But for True and False, we would rather have > > if n is True: > > not > > if n==True: > > correct?  I've seen that cause some problems in code I've reviewed, > where things that shouldn't be True were True. > I would use If n: If you want to mak

Re: [sage-devel] "is" and python integers

2010-07-28 Thread Robert Bradshaw
On Wed, Jul 28, 2010 at 1:28 PM, William Stein wrote: > On Wed, Jul 28, 2010 at 1:14 PM, Jason Grout > wrote: >> Someone pointed this out to me recently, and it sounded like a useful gotcha >> to know about python.  Apparently small python integers are cached, while >> larger ones are not.  Somet

Re: [sage-devel] "is" and python integers

2010-07-28 Thread William Stein
On Wed, Jul 28, 2010 at 1:14 PM, Jason Grout wrote: > Someone pointed this out to me recently, and it sounded like a useful gotcha > to know about python.  Apparently small python integers are cached, while > larger ones are not.  Sometimes. > > % sage -ipython > Python 2.6.4 (r264:75706, May 25 2

[sage-devel] "is" and python integers

2010-07-28 Thread Jason Grout
Someone pointed this out to me recently, and it sounded like a useful gotcha to know about python. Apparently small python integers are cached, while larger ones are not. Sometimes. % sage -ipython Python 2.6.4 (r264:75706, May 25 2010, 15:42:09) Type "copyright", "credits" or "license" for m