functions, optional parameters
Rustom Mody
rustompmody at gmail.com
Sat May 9 23:35:33 EDT 2015
On Sunday, May 10, 2015 at 8:16:07 AM UTC+5:30, Steven D'Aprano wrote:
> I predict that the majority of the time, late binding would just be a
> pointless waste of time:
>
> def process_string(thestr, start=0, end=None, slice=1, reverse=True):
> pass
>
> Why would you want 0, None, 1 and True to be re-evaluated every time?
> Admittedly it will be fast, but not as fast as evaluating them once, then
> grabbing a static default value when needed. (See below for timings.)
>
And what is the work involved in (re)computing 0, None, 1, True??
If I write (... arg=square_root_of_grahams_number())
I would expect to pay for it.
If I write trivial defaults, then I expect trivial payment.
More information about the Python-list
mailing list