Treffer: Resource Management in Python.

Title:
Resource Management in Python.
Authors:
Schoenborn, Oliver1 oliver.schoenborn@utoronto.ca
Source:
Dr. Dobb's Journal: Software Tools for the Professional Programmer. Mar2005, Vol. 30 Issue 3, p54-57. 4p. 1 Black and White Photograph, 1 Diagram.
Database:
Business Source Premier

Weitere Informationen

This article discusses the subtleties of Python in resource management and some of the modules and techniques that one can use to get around them. In Python, resources are not available directly but are wrapped in higher level Python objects that one can instantiate and use in his or her own Python objects and functions. Resource management in Python is trivial 90 percent of the time because it is automated: once a person no longer need an object, one can just forget about it, and the interpreter does its best to eventually release it. This indeterminism is even a trap for experienced programmers who have a background in object-oriented languages that have deterministic destruction, where create-release pairs are used heavily, and to great effect. In Python, variable names are references to objects, not objects in and of themselves. While reference cycles are not a problem per se, they do prevent the reference count of all objects in the cycle from going to zero--even those not directly in the chain. An exception in a function causes the named references at all levels of the function call stack to be retained until the Python interpreter exists, in case one need to explore the data for debugging purposes.