On 9/27/2016 12:01 AM, srinivas devaki wrote:
how does Python switch execution and maintain context i.e function stack
etc,.. for co-routines and why is it less costly than switching threads
which almost do the same, and both are handled by Python Interpreter
itself(event loop for co-routines and GIL scheduling for threading), so
where does the extra overhead for threads come from ?

Thread switching is done by the interpreter, either when a thread calls a blocking i/o function or when a time slice expires. You can read the asyncio.base_event code and other submodules for details on how asyncio works.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to