Danek Duvall wrote:
Shawn Walker wrote:

[email protected] wrote:

 - Is there something special about how we tell if a pfmri exists?
   There are a bunch of places where 'if pfmri' has been changed to 'if
   pfmri is not None' and 'if not pfmri.publisher' was changed to 'if
   pfmri.publisher is None.'  This seems counterintuitive, which is why
   I'm curious about this part of the change.
The best explanation (assuming it is accurate) I've found is here:

http://stackoverflow.com/questions/100732/why-is-if-not-someobj-better-than-if-someobj-none-in-python

In short, "is None" is the most efficient comparison test for an object.
Using a simple boolean test causes python to perform an extra conversion.

It also prevents silly bugs where a False value other than None has been
specified.  So I test explicitly for None since that is the only "False"
case I'm expecting.

In general, I'd rather see the bare boolean test, rather than a direct
comparison with None.  The only times we should see a comparison against
None (which should always be done with "is", and not with "==") is when
other False-evaluating values need to be handled differently, or when
there's a bug in the underlying __boolean__() method (or lack thereof; cf
dbm).

I have no strong feelings here, although I wish we were more consistent. I've seen "is None" and "== None" sprinkled here and in various places in our codebase.

I'll revert to boolean tests here.

Cheers,
--
Shawn Walker
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to