[Python-ideas] @run_as_thread decorator
Georg Brandl
g.brandl at gmx.net
Sat Mar 5 17:43:53 CET 2011
On 05.03.2011 17:32, Antoine Pitrou wrote:
> On Sat, 05 Mar 2011 17:15:37 +0100
> Georg Brandl <g.brandl at gmx.net> wrote:
>> On 05.03.2011 17:08, Antoine Pitrou wrote:
>> > On Sat, 05 Mar 2011 16:56:21 +0100
>> > Georg Brandl <g.brandl at gmx.net> wrote:
>> >>
>> >> > I'm rather opposed to this, it's a useless addition to the API with no
>> >> > real point. Calling the Thread() constructor works basically ok.
>> >>
>> >> Problem is, the one-liner doesn't give you a reference to the Thread object.
>> >
>> > It does if you don't call start() :)
>>
>> Then it's not a one-liner anymore :)
>
> But neither is the original proposal!
>
> @run_in_thread
> def foo():
> ...
>
> t = foo()
It's an asymptotic one-liner: every invocation after the first one is
a true one-liner :)
Georg
More information about the Python-ideas
mailing list