>
>
> Here is more real example.
>
> >>> def square(x): y = x*x; return y
> ...
> >>> import dis
> >>> dis.dis(square)
>  1           0 LOAD_FAST                0 (x)
>              3 LOAD_FAST                0 (x)
>              6 BINARY_MULTIPLY
>              7 STORE_FAST               1 (y)
>             10 LOAD_FAST                1 (y)
>             13 RETURN_VALUE
>
> As you see the interpreter is pretty stupid. It is loading x twice and
> unnecessarily storing and loading y.
>
> Anand
> _______________________________________________
>  <http://mail.python.org/mailman/listinfo/bangpypers>
>

Is interpreter too stupid or is the python compiler that creates the
bytecoded file, too simple and ignoring optimizations on the bytecode it
creates. I think its the later? please correct me

-- 
Thanks and best regards,
Vishal Sapre

---

"So say...Day by day, in every way, I am getting better, better and better
!!!"
"A Strong and Positive attitude creates more miracles than anything else.
Because...Life is 10% how you make it, and 90% how you take it"
"Diamond is another piece of coal that did well under pressureā€
"Happiness keeps u Sweet, Trials keep u Strong,
Sorrow keeps u Human, Failure Keeps u Humble,
Success keeps u Glowing, But only God Keeps u Going.....Keep Going....."
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to