[Python-Dev] PEP 574 -- Pickle protocol 5 with out-of-band data

Chris Angelico rosuav at gmail.com
Thu Mar 29 05:01:06 EDT 2018


On Thu, Mar 29, 2018 at 7:56 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 29 March 2018 at 09:49, Chris Angelico <rosuav at gmail.com> wrote:
>> On Thu, Mar 29, 2018 at 7:18 PM, Nathaniel Smith <njs at pobox.com> wrote:
>>> Another example is the multiprocessing module: it's very safe to
>>> assume that the parent and the child are using the same interpreter
>>> :-). There's no fundamental reason you shouldn't be able to send
>>> bytecode between them.
>>
>> You put a smiley on it, but is this actually guaranteed on all
>> platforms? On Unix-like systems, presumably it's using fork() and thus
>> will actually use the exact same binary, but what about on Windows,
>> where a new process has to be spawned? Can you say "spawn me another
>> of this exact binary blob", or do you have to identify it by a file
>> name?
>>
>> It wouldn't be a problem for the nonportable mode to toss out an
>> exception in weird cases like this, but it _would_ be a problem if
>> that causes a segfault or something.
>
> If you're embedding, you need multiprocessing.set_executable()
> (https://docs.python.org/3.6/library/multiprocessing.html#multiprocessing.set_executable),
> so in that case you definitely *won't* have the same binary...

Ah, and that also showed me that forking isn't mandatory on Unix
either. So yeah, there's no assuming that they use the same binary.

I doubt it'll be a problem to pickle though as it'll use some form of
versioning even in NONPORTABLE mode right?

ChrisA


More information about the Python-Dev mailing list