[Python-Dev] API and process questions (sparked by Claudiu Popa on 16104

Charles-François Natali cf.natali at gmail.com
Mon Apr 28 18:56:06 CEST 2014


>> (2)  The patch adds new functionality to use multiple processes in
>> parallel.  The normal parameter values are integers indicating how
>> many processes to use.  The parameter also needs two special values --
>> one to indicate "use os.cpu_count", and the other to indicate "don't
>> use multiprocessing at all".
>>
>> (A)  Is there a Best Practices for this situation, with two odd cases?
>
>
> No. In this situation I would consider 0 or -1 for "use os.cpu_count' and
> None for "don't use multi-processing".

Why would the user care if multiprocessing is used behind the scene?
It would be strange for processes=1 to fail if multiprocessing is not
available.

If you set a default value of 1, then compileall() will work
regardless of whether multiprocessing is available.

In short:
processes <= 0: use os.cpu_count()
processes == 1 (default): just use normal sequential compiling
processes > 1: use multiprocessing

There's no reason to introduce None. Or am I missing something?


More information about the Python-Dev mailing list