On Fri, Mar 16, 2018 at 12:38 AM, George Fischhof <geo...@fischhof.hu> wrote: > > > " if new file functions are added, they will go only in pathlib, > which makes pathlib effectively mandatory;" > Yes but I think this part of the evolution: slowly everyone will shift to > pathlib, > and being mandatory is true for the current status as well: if you need a > function, you need the module. > Right now if you wan to execute some file operations, you need os plus > shutil, because the half of the > functions are in one of them, the other half is in the other module
The os module is cheap; pathlib has a definite cost. If every file operation goes through pathlib, that basically means pathlib becomes part of the startup cost: rosuav@sikorsky:~$ python3 -m timeit -s 'import subprocess, sys, pathlib' 'subprocess.check_call([sys.executable, "-c", "import os"])' 50 loops, best of 5: 8.82 msec per loop rosuav@sikorsky:~$ python3 -m timeit -s 'import subprocess, sys, pathlib' 'subprocess.check_call([sys.executable, "-c", "import pathlib"])' 20 loops, best of 5: 15.9 msec per loop rosuav@sikorsky:~$ python3.6 -m timeit -s 'import subprocess, sys, pathlib' 'subprocess.check_call([sys.executable, "-c", "import os"])' 100 loops, best of 3: 14.1 msec per loop rosuav@sikorsky:~$ python3.6 -m timeit -s 'import subprocess, sys, pathlib' 'subprocess.check_call([sys.executable, "-c", "import pathlib"])' 10 loops, best of 3: 19.7 msec per loop rosuav@sikorsky:~$ python3.5 -m timeit -s 'import subprocess, sys, pathlib' 'subprocess.check_call([sys.executable, "-c", "import os"])' 100 loops, best of 3: 10.6 msec per loop rosuav@sikorsky:~$ python3.5 -m timeit -s 'import subprocess, sys, pathlib' 'subprocess.check_call([sys.executable, "-c", "import pathlib"])' 100 loops, best of 3: 18.7 msec per loop And this is with warm caches; for a true first-time startup, the cost could be significantly higher. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/