On Mon, Jan 11, 2021 at 6:06 AM Paul Moore <[email protected]> wrote: > > On 2021-01-10 at 18:38:12 +0100, > Alex Prengère <[email protected]> wrote: > > 3. Use timeit. The scripts have no side effects so repeating their > > execution the way timeit does, works for me. The only issue is that, > > as far as I know, timeit only allows statements as input parameters, > > not the whole script, like for example: > > $ python -m timeit --script script.py > > There's always > > py -m timeit -s "from pathlib import Path; data = > Path('your_script.py').read_text()" "exec(data, globals())" >
Depending on what's being measured, that might not be an accurate measurement. After the first execution, all imports will be resolved out of sys.modules. ChrisA _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/LZ5KETBUVJE23BORDO2PJHBHWPPFMFBL/ Code of Conduct: http://python.org/psf/codeofconduct/
