[Python-Dev] Issues with PEP 482 (1) (original) (raw)

Paul Sokolovsky pmiscml at gmail.com
Tue Apr 28 21:39:41 CEST 2015


Hello,

On Tue, 28 Apr 2015 19:44:53 +0100 Mark Shannon <mark at hotpy.org> wrote:

[]

A coroutine without a yield statement can be defined simply and concisely, thus:

@coroutine def f(): return 1

[]

A pure-python definition of the "coroutine" decorator is given below.

[]

from types import FunctionType, CodeType

COCOROUTINE = 0x0080 COGENERATOR = 0x0020 def coroutine(f): 'Converts a function to a generator function' oldcode = f.code newcode = CodeType( oldcode.coargcount, oldcode.cokwonlyargcount,

This is joke right? This code has nothing to do with Python. This code deals with internal implementation details of CPython. No other Python implementation would have anything like that (because then it would be just another CPython, and there's clearly no need to have two or more CPythons). The code above is as helpful as saying "you can write some magic values at some magic memory addressed to solve any problem you ever have".

All that is rather far away from making coroutine writing in Python easier and less error-prone, which is the topic of PEP482.

-- Best regards, Paul mailto:pmiscml at gmail.com



More information about the Python-Dev mailing list