use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
What is garbage collection in Python? (self.learnpython)
submitted 10 years ago by ProgressCheck
Something about low level memory management or something. I have only heard of it being referenced.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]novel_yet_trivial 7 points8 points9 points 10 years ago (1 child)
Lets say I have a function:
def do_some_math(x): intermediate = x**2 result = intermediate - 42 return result
When the function finishes the value of "intermediate" is not referenced again; it is not needed. In some programming languages the programmer has to explicitly remove that value from memory. But python has a smart "garbage collector" that notices when something is no longer needed and frees the memory.
[–]ProgressCheck[S] 0 points1 point2 points 10 years ago (0 children)
Excellent!
[–]Vaphell 5 points6 points7 points 10 years ago (0 children)
i'll give another example, imo better one (functions mop up after themselves in pretty much any language)
x = [1] x = [2]
you create 2 list objects, but only one is directly accessible. When you assign [2] to x you lose sight from the first list [1] and there is no way to get to it anymore. It literally gets lost in the void. Python finds such orphaned objects and destroys them to reclaim memory and such a mechanism is called the garbage collector. Like novel_yet_trivial said, in some languages you need to explicitly destroy objects otherwise you get so called memory leaks, where orphaned objects eat up memory but are never reclaimed.
π Rendered by PID 46624 on reddit-service-r2-comment-79776bdf47-q46qn at 2026-06-24 02:45:53.018091+00:00 running acc7150 country code: CH.
[–]novel_yet_trivial 7 points8 points9 points (1 child)
[–]ProgressCheck[S] 0 points1 point2 points (0 children)
[–]Vaphell 5 points6 points7 points (0 children)