[FRPythoneers] Python documentation and default expression

Mike Olson Mike.Olson at fourthought.com
Sun Mar 17 08:02:33 MST 2002


On Fri, 2002-03-15 at 15:28, Rob Riggs wrote:
> Mike Olson wrote:
> 
> >
> As I've just discovered. I think I will be much more careful about this 
> in the future.
> 
> If it doesn't do so already, this sounds like it could be a valuable 
> test in PyChecker.

I don't think it does.  I'm not sure if it could.  How does it know what
you intend...

> 
> > 
> >also, if your counting clock cycles, 
> >
> >if foo is not None:
> >
> >will actually be quicker.
> >
> I've almost always used "if foo != None:". Is there a reason not to 
> write it as such?

"is" is an identity check.  At the C level, it compares pointer values
(one clock cycle).  When you use "=", which is equality, it has to go
through (possiblly) all of the coercion routines, look for __cmp__ etc
so it will be slower.

For most applications it doesn't matter.  I never ran into it until I
worked on optimizating of our Xslt processor.  There, we were hitting if
statements 10,000 times and then we would see large differences.

Mike


> 
> -Rob
> 
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers
-- 
Mike Olson                                Principal Consultant
mike.olson at fourthought.com                +1 303 583 9900 x 102
Fourthought, Inc.                         http://Fourthought.com 
4735 East Walnut St,                      http://4Suite.org
Boulder, CO 80301-2537, USA
XML strategy, XML tools, knowledge management




More information about the FRPythoneers mailing list