Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:04:44+00:00 2026-06-04T08:04:44+00:00

This question is an extension of a question I asked earlier: Python Delegate Pattern

  • 0

This question is an extension of a question I asked earlier: Python Delegate Pattern – How to avoid circular reference? After reading the replies, I decided to clarify my question, but was requested to post it separately.

Here goes:

  1. A passage in the Python docs (reproduced below) states that garbaged collection is not guaranteed for circular
    referenced objects. A post I found here suggests the same thing. But the replies to my earlier question disagrees. So, have I misunderstood the passage or are there further
    details that I’ve missed?
  2. I suppose using a weak reference, as stated in Alex Martelli’s reply to the question Should I worry about circular references in Python? would avoid the overhead for garbage collecting circular referenced objects mentioned in his reply entirely? If so how does it work?

The relevant Python docs that suggests conflicting following passage from Python’s doc:

CPython implementation detail: CPython currently uses a
reference-counting scheme with (optional) delayed detection of
cyclically linked garbage, which collects most objects as soon as they
become unreachable, but is not guaranteed to collect garbage
containing circular references
. See the documentation of the gc module
for information on controlling the collection of cyclic garbage. Other
implementations act differently and CPython may change. Do not depend
on immediate finalization of objects when they become unreachable (ex:
always close files).

The passage in its original form can be found here: http://docs.python.org/reference/datamodel.html The bold setting is mine.

Thanks in advance for any replies.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:04:45+00:00Added an answer on June 4, 2026 at 8:04 am

    I believe that the most important reason that objects with circular references aren’t guaranteed to be collected is that, by design, Python never collects objects with circular references if they define a __del__ method. There is a pretty straightforward reason:

    Python doesn’t collect such cycles automatically because, in general, it isn’t possible for Python to guess a safe order in which to run the __del__() methods.

    I am loath to say that this is the only reason unreachable objects with circular references might not be detected. There are probably a few unusual situations that could foil the GC’s cycle detection mechanisms. But unless you define __del__ for one of your objects, you’re probably ok. Just don’t worry about it, and use the GC’s extensive debugging options if you see performance issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: This is an extension of an earlier question I asked here: Do additional
Note: This is an extension of an earlier question I asked here: Do additional
I have asked this question earlier, please click here ! this is extension to
This is an extension for this question asked an hour ago. We cannot modify
This is an extension / next step of this question I asked a few
This is an extension of a question I previously asked here . Long story
This is an extension to a question which I asked some time ago. I
This is an extension to the question I asked here: Get text from clipboard
I know that this question was asked earlier but the OP didn't get any
This is an extension of an earlier questions I asked, here: Django - Parse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.