<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 06.08.2015 17:52, Xavier Combelle wrote:<br>
<blockquote
cite="mid:CAEQcUJQbnLjQsDjSjEHsw13pc60x+LZJP99m8aPxOVHhOwVS4Q@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><span class="">
<blockquote type="cite">
<div>One quick comment: from my experience (mostly
with other languages that are very different from
Python, so I can't promise how well it applies
here...), implicit futures without implicit
laziness or even an explicit delay mechanism are
not as useful as they look at first glance. Code
that forks off 8 Fibonacci calls, but waits for
each one's result before forking off the next one,
might as well have just stayed sequential. And if
you're going to use the result by forking off
another job, then it's actually more convenient to
use explicit futures like the ones in the stdlib.</div>
<div><br>
</div>
<div>One slightly bigger idea: If you really want to
pursue your implicit-as-possible design further,
you might want to consider making the decorators
replace the function with an object whose __call__
method just implicitly submits it to the pool.</div>
</blockquote>
<br>
</span> I added two new decorators for this. But they
don't work with the @ syntax. It seems like a well-known
issue of Python:<br>
<br>
_pickle.PicklingError: Can't pickle <function
fib_fork at 0x7f8eaeb09730>: it's not the same object
as __main__.fib_fork<br>
<br>
Would be great if somebody could fix that.<span class=""></span><br>
</div>
</blockquote>
<div><br>
</div>
<div>Sorry but I don't follow you have you any example that
fail ? <br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
I fixed that, well, halfhearted:<br>
<br>
<a class="moz-txt-link-freetext" href="https://github.com/srkunze/fork/blob/2359265/fork.py#L47">https://github.com/srkunze/fork/blob/2359265/fork.py#L47</a> and the
following 3 lines.<br>
<br>
Remove that lines, and the tests using @cpu_bound_fork will fail.<br>
<br>
The reason for this is that the Pickle module is only capable of
pickling module-level-named objects.<br>
<br>
<br>
Do you have a better fix? I would rather see that fixed in the
Python internal decorator implementation than by me.<br>
<br>
<br>
Cheers,<br>
Sven<br>
</body>
</html>