why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?
ckaynor at zindagigames.com
Tue Aug 18 00:57:22 CEST 2015
On Mon, Aug 17, 2015 at 3:25 PM, <alex.flint at gmail.com> wrote:
> Sorry I completely mistype that. It was supposed to read:
> >>> id(multiprocessing.Process.is_alive) ==
What is going on here is that it get multiprocessing.Process.is_alive,
computes the id of it, then throws away the value of
multiprocessing.Process.is_alive. It then does the same thing for
multiprocessing.Process.start, where by it happens to reuse the id of the
> >>> multiprocessing.Process.is_alive is multiprocessing.Process.start
In this case, the "is" operator keeps both references around during its
call, and therefore they will get different ids.
The rules for the id is that they are only guaranteed unique during the
lifespan of both objects. Also, generally, you do not want to use id or is
for much of anything unless you really know what you are doing - generally,
you just want == instead.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list