One of the most important design choices in CPython is its use of reference counting as the primary memory management strategy. Every object in Python keeps track of how many references point to it. When that count drops to zero, the memory is immediately reclaimed. This has an interesting side effect: object destruction in Python is often deterministic. In many cases, you can predict exactly when an object will be cleaned up, which is not true in runtimes that rely purely on tracing garbage collectors. However, reference counting alone cannot handle cyclic references. That’s why CPython also includes a generational garbage collector to detect and clean up unreachable cycles. The combination of immediate cleanup (via reference counting) and periodic cycle detection is a deliberate trade-off between performance and safety. Understanding this internal behavior is especially useful when building high-throughput backend services or debugging unexpected memory growth. #Python #RuntimeInternals #MemoryManagement #SoftwareEngineering
Python's Reference Counting Memory Management Strategy
More Relevant Posts
-
Matmath v4.0.0-rc1 is now available. This release focuses on performance and correctness. 👉 Added CPython support for faster calculations when compared to the previous python-only solution. 👉 Fixed a bug in Matrix initialization that could produce incorrect state in some cases. 👉 Fixed a bug in bool(Vector) evaluation. PyPI: https://lnkd.in/gSCmxe_z Repo: https://lnkd.in/gHntrufh #python #numericalcomputing #opensource #softwareengineering #math #devtools
To view or add a comment, sign in
-
Matmath v4.0.0 (Stable release) is now available. This release fixes a few things over the last release, namely: - Addition of `matmath.legacy` for backward compatibility - Usage of `matmath.legacy` as a fallback to the CPython implementations instead of throwing an ImportError PyPI: https://lnkd.in/gW84uupa Repo: https://lnkd.in/gHntrufh #python #numericalcomputing #opensource #softwareengineering #math
Matmath v4.0.0-rc1 is now available. This release focuses on performance and correctness. 👉 Added CPython support for faster calculations when compared to the previous python-only solution. 👉 Fixed a bug in Matrix initialization that could produce incorrect state in some cases. 👉 Fixed a bug in bool(Vector) evaluation. PyPI: https://lnkd.in/gSCmxe_z Repo: https://lnkd.in/gHntrufh #python #numericalcomputing #opensource #softwareengineering #math #devtools
To view or add a comment, sign in
-
Visualizing Graphs in Orchestrator with Python, Matplotlib and ByteBuffer What if you could generate professional-grade, real-time resource graphs—like Host CPU/Memory utilization—and store them directly as Image Resource Elements inside vRO itself? Today, I will be talking about one such POC in this post. By combining the power of vRO's Python Action Environments, the pyVmomi SDK, and Matplotlib, and vro's ByteBuffer clss, we will try to turn vRO into a graphing engine.... - https://lnkd.in/gHVHsW5p
To view or add a comment, sign in
-
-
Visualizing Graphs in Orchestrator with Python, Matplotlib and ByteBuffer What if you could generate professional-grade, real-time resource graphs—like Host CPU/Memory utilization—and store them directly as Image Resource Elements inside vRO itself? Today, I will be talking about one such POC in this post. By combining the power of vRO's Python Action Environments, the pyVmomi SDK, and Matplotlib, and vRO ByteBuffer class, we will try to turn vRO into a graphing engine.... - https://lnkd.in/gKVhYaMn
To view or add a comment, sign in
-
-
DietPi 10.1 brings a NanoPi Zero2 image, introduces AI-powered WhoDB software, extends Navidrome to RISC-V, and includes several updates for Python, MinIO, and remote desktop tools like TigerVNC, RealVNC, and XRDP. https://lnkd.in/dmt9KX2X
To view or add a comment, sign in
-
-
Just learned about CuPy, which might be the easiest way to run GPU operations through Python. I was trying to do billions of ECI -> AzEl rotations, and that script had an absurd runtime. However, converting everything to C++ or writing CUDA kernels was more complexity than I wanted for a small project. I ended up trying CuPy, which is basically NumPy but it runs on your GPU. In practice, most of the change was just replacing “np” with “cp.” The speedup was incredible and required very little extra effort, i highly recommend checking it out.
To view or add a comment, sign in
-
The deeper your data is nested, the harder validation errors are to trace. With dataclass, you’ll see the value that failed, but not where it failed. In complex nested structures, that makes debugging frustrating. Pydantic includes the full path from the root model to the exact field that triggered the error, so you immediately know where to look. In my free interactive course, you can run both examples in your browser and compare the error output side by side. 🚀 Try the course: https://bit.ly/46tDojF #Python #DataScience #InteractiveLearning #Pydantic
To view or add a comment, sign in
-
-
#Day - 32 LeetCode #334 – Increasing Triplet Subsequence (Medium) In this problem, the goal was to determine whether an array contains an increasing triplet subsequence in O(n) time and O(1) space complexity. 🔹 Approach Used: Maintained two variables (first and second) initialized to infinity. Iterated through the array once. Updated first and second dynamically. Returned True when a valid third element was found. This problem strengthened my understanding of: ✅ Greedy algorithms ✅ Optimized space complexity ✅ Efficient single-pass solutions ✅ Logical thinking for edge cases Under the Guidance of : Rudra Sravan kumar #LeetCode #ProblemSolving #Python #DataStructures #Algorithms #CodingJourney #SoftwareDeveloper
To view or add a comment, sign in
-
-
Day 20: Smallest Window Containing All Characters Task: Find the smallest substring in a given string that contains all the characters (including duplicates) of another target string. Solution: Sliding Window + Frequency Hashing. This is a classic "Hard" level string problem! Instead of brute-forcing all possible substrings, I optimized the solution to O(N) using a dynamic sliding window. First, I mapped the required character frequencies of the target string. Then, I expanded the window using a right pointer until all necessary characters were collected. The real magic happens next: shrinking the window from the left by dropping extra or unneeded characters to find the absolute minimum valid length. A fantastic exercise in pointer manipulation and hashing! #geekstreak60 #npci #codingchallenge #dailylearning #programmer #python #slidingwindow #algorithms
To view or add a comment, sign in
-
-
Not much people even to mention, but we are finally free from GIL in Python since October 2025 (3.15 v). Check it out, we have fully functional multithreading with physical threads. This opens us opportunities to process CPU bound tasks without blocking async process, for example: encoding/decoding JWT by offload without using multiprocessing hack and encrypting hashing password keys. I will provide some example of usage in near future. Please, share your thoughts on that. #python #multithreading #highload
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development