On 8 February 2012 00:01, Steven D'Aprano <st...@pearwood.info> wrote:

> Sarma Tangirala wrote:
>
>  Is is better to use pow() against **?
>>
>
>
> Advantages of **
>
> - it is shorter to type x**y vs pow(x, y)
> - being an operator, it is slightly faster than calling a function
> - you can't monkey-patch it
>
> Disadvantages of **
>
> - being an operator, you can't directly use it as a function-object
> - it can't take three arguments
> - hard to google for "**"
> - you can't monkey-patch it
>
> Advantages of pow()
>
> - it is a function, so you can pass it around as an object
> - three argument form
> - easy to call help(pow) to see documentation
> - easy to google for "pow"
> - can be monkey-patched
>
> Disadvantages of pow()
>
> - a tiny bit slower due to the function call
> - slightly longer to type
> - can be monkey-patched
>
>
> Weigh up the advantages and disadvantages of each, and make the call which
> is better for you.
>
> (My preference is to use the ** operator.)
>
>
A simple "function call" argument would have done! :D Thanks for the survey!

Anyway, I was wondering about this, if internally pow() actually uses **. :P


>
>
> --
> Steven
>
> ______________________________**_________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>



-- 
Sarma Tangirala,
Class of 2012,
Department of Information Science and Technology,
College of Engineering Guindy - Anna University
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to