How is Python designed?

Limin Fu fulimin_yuan at yahoo.com
Wed Dec 8 18:07:56 CET 2004


> So maybe you're right in claiming it beeing
> recursive. But then,
> depth-traversal is recursive, too.

No, in the depth-traversal implementation, a function
can avoid calling itself (at least in my
implementation it's like this). 

Because you can write seperate functions: a function
for depth-traversal (say trav()) and another function
for evaluation (say eval()). trav() may call eval().
And eval() NEVER call other functions. For one
arithmetic tree, trav() is called once, and eval() is
called by trav() at each node. So it is not recursive.


> Now apart from that, I still fail to see where your
> method of evaluation has
> any speed gains. 

And if you inplement eval() as an "inline" function,
there will be no cost for function calls for eval().
In this way it can gain some speeds.

Best regards,

Limin



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250



More information about the Python-list mailing list