[sage-devel] Re: timing and debugging

2008-09-11 Thread Justin Walker
Hi, Mike, On Sep 9, 2008, at 9:34 PM, Mike Hansen wrote: What's the difference between == and is (or, more to the point: where is this discussed)? This is a Python thing as == is equality testing and is is memory address testing. For example, sage: a = 2 sage: b = 2 sage: a == b True

[sage-devel] Re: timing and debugging

2008-09-10 Thread Jason Grout
Justin Walker wrote: On Sep 9, 2008, at 7:25 PM, Jason Grout wrote: Jason Merrill wrote: On Sep 9, 6:35 pm, Justin Walker [EMAIL PROTECTED] wrote: Hi, all, There may be a more pythonic way to do this--I'm just trying to translate something I saw in Ruby. I think I've seen at least one

[sage-devel] Re: timing and debugging

2008-09-09 Thread Mike Hansen
Hi Justin, I'm not sure about the other stuff, but you should do is None instead of == None since your times are so low. sage: a = 2 sage: timeit(a == None) 625 loops, best of 3: 420 µs per loop sage: timeit(a is None) 625 loops, best of 3: 143 ns per loop --Mike

[sage-devel] Re: timing and debugging

2008-09-09 Thread Jason Merrill
On Sep 9, 6:35 pm, Justin Walker [EMAIL PROTECTED] wrote: Hi, all, Whilst looking at some code, I noticed that a computation was being   repeated on each call, although the inputs to the computation never   changed (these were values used to define an instance of a class).  I   decided to

[sage-devel] Re: timing and debugging

2008-09-09 Thread Jason Grout
Jason Merrill wrote: On Sep 9, 6:35 pm, Justin Walker [EMAIL PROTECTED] wrote: Hi, all, There may be a more pythonic way to do this--I'm just trying to translate something I saw in Ruby. I think I've seen at least one person define an @cache decorator somewhere on the web. I believe we

[sage-devel] Re: timing and debugging

2008-09-09 Thread Justin Walker
Hey, Mike, Thanks for this... On Sep 9, 2008, at 3:42 PM, Mike Hansen wrote: I'm not sure about the other stuff, but you should do is None instead of == None since your times are so low. sage: a = 2 sage: timeit(a == None) 625 loops, best of 3: 420 µs per loop sage: timeit(a is None)

[sage-devel] Re: timing and debugging

2008-09-09 Thread Justin Walker
On Sep 9, 2008, at 7:25 PM, Jason Grout wrote: Jason Merrill wrote: On Sep 9, 6:35 pm, Justin Walker [EMAIL PROTECTED] wrote: Hi, all, There may be a more pythonic way to do this--I'm just trying to translate something I saw in Ruby. I think I've seen at least one person define an

[sage-devel] Re: timing and debugging

2008-09-09 Thread Justin Walker
On Sep 9, 2008, at 4:36 PM, Jason Merrill wrote: On Sep 9, 6:35 pm, Justin Walker [EMAIL PROTECTED] wrote: [snip] I can't tell if this is just an artifact of some funky debugging interaction (am I debugging the debugger?), or whether this is really where the code goes. Anyone have a clue

[sage-devel] Re: timing and debugging

2008-09-09 Thread Mike Hansen
Hi Justin, What's the difference between == and is (or, more to the point: where is this discussed)? This is a Python thing as == is equality testing and is is memory address testing. For example, sage: a = 2 sage: b = 2 sage: a == b True sage: id(a) 54737440 sage: id(b) 54735856 sage: a is

[sage-devel] Re: timing and debugging

2008-09-09 Thread Justin Walker
Hi, Mike, On Sep 9, 2008, at 9:34 PM, Mike Hansen wrote: What's the difference between == and is (or, more to the point: where is this discussed)? This is a Python thing as == is equality testing and is is memory address testing. For example, Thanks for the quick tutorial; that explains