Às 07:30 de 21-01-2016, Paulo da Silva escreveu:
> Hi all.
>
> What is the fastest implementation of the following code?
>
> def g(p):
> ...
> return something
>
> def f1(p="p1"):
> return g(p)
>
> def f2(p="p2"):
> return g(p)
>
Thanks to all who responded.
I'll try
On Thu, 21 Jan 2016 06:30 pm, Paulo da Silva wrote:
> Hi all.
>
> What is the fastest implementation of the following code?
Let's find out. Here are three different ways to do it:
def g(p):
return
def f1(p=3): # argument with a default
return g(p)
def f2(): # no argument at all
Paulo da Silva wrote:
> Hi all.
>
> What is the fastest implementation of the following code?
>
> def g(p):
> ...
> return something
>
> def f1(p="p1"):
> return g(p)
>
> def f2(p="p2"):
> return g(p)
>>> def g(p): return p.upper()
...
>>> def f1(): pass
...
>>> f1.__code__ = g.__code__
>>>
Apparently the thread poster cannot receive email, I just received a bounce
on my previous email :-/
On Thu, Jan 21, 2016, 08:49 Yann Kaiser wrote:
> partial treats keyword arguments as default values, though they become
> keyword-only as a result :
>
> f1 = functools.partial(g, p="p1")
>
> On T
partial treats keyword arguments as default values, though they become
keyword-only as a result :
f1 = functools.partial(g, p="p1")
On Thu, Jan 21, 2016, 08:35 Paulo da Silva
wrote:
> Hi all.
>
> What is the fastest implementation of the following code?
>
> def g(p):
> ...
> ret
Hi all.
What is the fastest implementation of the following code?
def g(p):
...
return something
def f1(p="p1"):
return g(p)
def f2(p="p2"):
return g(p)
Thanks
Paulo
--
https://mail.python.org/mailman/listinfo/python-list