although it' lower-level topic than you generally need to do useful thread work in pythonthe implementation of python' threads can have impacts on both performance and coding this section summarizes implementation details and some of their ramifications threads implementation in the upcoming python this section describes the current implementation of threads up to and including python at this writingpython is still in developmentbut one of its likely enhancements is new version of the gil that provides better performanceespecially on some multicore cpus the new gil implementation will still synchronize access to the pvm (python language code is still multiplexed as before)but it will use context switching scheme that is more efficient than the current -bytecode-instruction approach among other thingsthe current sys setcheckinterval call will likely be replaced with timer duration call in the new scheme specificallythe concept of check interval for thread switches will be abandoned and replaced by an absolute time duration expressed in seconds it' anticipated that this duration will default to millisecondsbut it will be tunable through sys setswitchinterval moreoverthere have been variety of plans made to remove the gil altogether (including goals of the unladen swallow project being conducted by google employees)though none have managed to produce any fruit thus far since cannot predict the futureplease see python release documents to follow this (well thread strictly speakingpython currently uses the global interpreter lock (gilmechanism introduced at the start of this sectionwhich guarantees that one threadat mostis running code within the python interpreter at any given point in time in additionto make sure that each thread gets chance to runthe interpreter automatically switches its attention between threads at regular intervals (in python by releasing and acquiring the lock after number of bytecode instructionsas well as at the start of longrunning operations ( on some file input/output requeststhis scheme avoids problems that could arise if multiple threads were to update python system data at the same time for instanceif two threads were allowed to simultaneously change an object' reference countthe result might be unpredictable this scheme can also have subtle consequences in this threading examplesfor instancethe stdout stream can be corrupted unless each thread' call to write text is synchronized with thread locks moreovereven though the gil prevents more than one python thread from running at the same timeit is not enough to ensure thread safety in generaland it does not threads