``if t'' vs ``if t is not None''

jno at glasnet.ru jno at glasnet.ru
Thu Apr 22 07:42:35 EDT 1999


hi there,

i faced a VERY strange behaviour of if-test operation!

	   ``if t'' != ``if t is not None''
	where ``t'' is None or a class instance

i was writing a threader for a news reader.
and found occasional hangs of a routine which builds the sequence of message
numbers for "read next" operation.
digging deeper brought me strange results: replacing ``if t'' with
``if t is not None'' speeded up the things dramatically!

the call contecst:

      for x in self.keys() :
        m, t = self.mesg_list[ x ]   
        self.Sequence.append( m.num )
        if t is not None :
          t.buildSequence(i+1)
          self.Sequence.extend( t.Sequence )
          del t.Sequence ; t.Sequence = None # trash extra data

can anyone explain me such a phenomenon???

-- 
SY,                       [ mailto:jno at glas.apc.org    ]
jno (PRIVATE PERSON)      [ http://www.glasnet.ru/~jno ]
a GlasNet techie          [ http://www.aviation.ru/    ]
If God meant man to fly, He'd have given him more money.




More information about the Python-list mailing list