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/2005-May/053923.html below:

[Python-Dev] Combining the best of PEP 288 and PEP 325: generator exceptions and cleanup

[Python-Dev] Combining the best of PEP 288 and PEP 325: generator exceptions and cleanup [Python-Dev] Combining the best of PEP 288 and PEP 325: generator exceptions and cleanupGuido van Rossum gvanrossum at gmail.com
Thu May 19 19:09:00 CEST 2005
[Phillip J. Eby]the only way a generator-iterator can become
> part of a cycle is via  an action taken outside the generator.  (E.g.
> passing it into itself via 'continue', creating a link from one of its
> arguments to it, etc.)  So, it's probably not a terrible limitation in
> practice.

It's enough to store a reference to the generator in a global (or in
anything that's reachable from a global). The generator's frame's
f_globals pointer then ensures the cycle.

Throwing an exception also provides ample opportunity for creating
cycles, since the frame hold a reference to the most recent traceback.
Ironically, throwing an exception with a traceback into a generator is
likely to cause a cycle because the traceback likely references the
throwing frame, which certainly has a reference to the generator...

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
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