Simple question about how the optimizer works

jb jblazi at hotmail.com
Thu May 9 05:48:55 EDT 2002


jb wrote:

> 
> Let us assume, f(x) is a relatively complicated function and g(x,y) and
> h(x,y) are functions.
> 
> How often is then f called in the following code:
> 
> print g(f(x),f(x))
> print h(f(x),f(x))
> 
> I think this topic is called "common subexppression elimination" in
> computer science.
> 
> TIA,

That was a dumb question, sorry. So I have tried and I am a bit surprised 
that f is called four times! 
Why?

-- 
Janos Blazi

"Il n'y a guère dans la vie qu'une préoccupation grave: c'est la mort;" 
(Dumas) 



-----------== Posted via Newsgroups.Com - Uncensored Usenet News ==----------
   http://www.newsgroups.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Ulimited Fast Downloads - 19 Servers =-----



More information about the Python-list mailing list