You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reduce number of instructions run and runtime. This is generally removing unnecessary work such as a TypeError always being constructed when FileIO is given a string filename. A second method is reducing GIL acquisitions in common paths. Measuring with the callgrind tool on my x64 linux desktop on an LTO build FileIO(path).readall() executes 23% fewer instructions and runs over 5% faster reading small files in full with these changes:
When FileIO is constructed on a filename string currently a TypeError is raised then caught because the constructor calls PyLong_AsInt then checks for an error rather than a fast inline _PyIndex_Check.
In FileIO.readall() do a single long GIL release rather than reacquiring the GIL for each read(). PyErr_CheckSignals is still checked at the same frequency.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Activity
pythongh-159446: Release the GIL less in FileIO open and readall
pythongh-159446: Avoid TypeError on FileIO construction