A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-April/139689.html below:

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

[Python-Dev] Issues with PEP 482 (1)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
> 
> CO_COROUTINE = 0x0080
> CO_GENERATOR = 0x0020
> 
> def coroutine(f):
>      'Converts a function to a generator function'
>      old_code = f.__code__
>      new_code = CodeType(
>          old_code.co_argcount,
>          old_code.co_kwonlyargcount,


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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4