touch module

Performance comparison between difference methods of doing ‘touch’ in Python.

class touch.Result(time, fn)[source]

Bases: object

Hold one performance result.

touch.create_test_file(filename, size)[source]

Create a test file at filename of size bytes.

touch.main()[source]

Start the performance test.

touch.make_used(*variables)[source]

Persuade linters that ‘variables’ are used.

touch.touch(filename, flags=66)

Touch a file using os.open+os.close - fastest on CPython 3.11.

touch.touch1(filename)[source]

Touch a file using pathlib - fastest on pypy3, and fastest overall - but has problems with non-UTF-8 filenames.

touch.touch2(filename)[source]

Touch a file using open+close.

touch.touch3(filename, flags=66)[source]

Touch a file using os.open+os.close - fastest on CPython 3.11.

touch.touch4(filename)[source]

Touch a file using open+close.