DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > Mollified About ResourceWarnings

Mollified About ResourceWarnings

A. Jesse Jiryu Davis user avatar by
A. Jesse Jiryu Davis
·
Jun. 06, 12 · Web Dev Zone · Interview
Like (0)
Save
Tweet
2.22K Views

Join the DZone community and get the full member experience.

Join For Free

Last month I griped about ResourceWarnings in Python 3, arguing they’re a useless irritation in a language that can clean up resources automatically. Python core developer Nick Coghlan responded in the comments and I understand the choice now.

Nick explains that ResourceWarnings reveal problems that would make the Python standard library inefficient running in PyPy. A resource like a socket can clean itself up promptly in CPython, but now that it issues a ResourceWarning when it isn’t explicitly closed, the socket helps library authors prepare for PyPy, in which resources are not promptly cleaned up. If I decide that lazy cleanup is ok, I can avoid ResourceWarnings by using a weakref callback to close the resource before it’s deleted, whenever that happens.

Nick also pointed out that ResourceWarnings are off by default in normal Python programs—I just saw them all the time because I usually run my code in nosetest.

Read our full discussion in the comments.

Props to Nick for taking the time to explain.

Python (language) code style Standard library Library dev CPython IT

Published at DZone with permission of A. Jesse Jiryu Davis, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Suspicious Sortings in Unity, ASP.NET Core, and More
  • How To Use Cluster Mesh for Multi-Region Kubernetes Pod Communication
  • An Overview of 3 Java Embedded Databases
  • Why to Implement GitOps into Your Kubernetes CI/CD Pipelines

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo