Trivial performance questions

Bryan belred1 at yahoo.com
Sat Oct 18 10:44:58 EDT 2003


  > If you *get into the habit* of always checking with "if x is None:"
> rather than "if x == None:" -- two equally readable constructs -- it
> will cost you no increase in effort whatsoever to always use the
> idiom you've gotten used to.  So, whether the (tiny) extra speed and
> readability are important or not, it's still a good habit to pick up.
  >
> Alex
> 

can you explain in more detail why "if x is None:" is better/faster than "if x == None:"?  i guess i don't fully 
understand "is".  my fingers always seem to want to type "if not x:", but that is probably worse still since it includes 
(), [], {}, '', False, None .

thanks,

bryan





More information about the Python-list mailing list