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 7835401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:36:58+00:00 2026-06-02T13:36:58+00:00

As I understand, sys.getrefcount() returns the number of references of an object, which should

  • 0

As I understand, sys.getrefcount() returns the number of references of an object, which “should” be 1 in the following case:

import sys,numpy
a = numpy.array([1.2,3.4])
print sys.getrefcount(a)

However, it turned out to be 2! So, if I:

del a

Will the “numpy.array([1.2,3.4])” object still be there (no garbage collection)?

  • 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-02T13:36:59+00:00Added an answer on June 2, 2026 at 1:36 pm

    When you call getrefcount(), the reference is copied by value into the function’s argument, temporarily bumping up the object’s reference count. This is where the second reference comes from.

    This is explained in the documentation:

    The count returned is generally one higher than you might expect,
    because it includes the (temporary) reference as an argument to
    getrefcount().

    As to your second question:

    If I “del a”, will the “numpy.array([1.2,3.4])” object still be there (no garbage collection)?

    By the time getrefcount() exits, the array’s reference count will to back to 1, and a subsequent del a would release the memory.

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

Sidebar

Related Questions

I am trying to understand the following code: #include<stdio.h> #include<stdlib.h> #include<sys/io.h> #define baseport 0x378
I'd like to understand the following issue: A process is doing write sys call
I understand that nltk can split sentences and print it out using the following
I'm trying to understand what the getaddrinfo function returns : #include <stdlib.h> #include <sys/types.h>
I was given to understand that calling print obj would call obj.__str__() which would
I have this .py file: from sys import argv script, filename = argv print
from sys import argv from os.path import exists script, from_file, to_file = argv print
In the below code I understand that sys.argv uses lists, however I am not
What is the big deal with HTTP.SYS in IIS 7? From what I understand,
I don't understand why this simple code # file: mp.py from multiprocessing import Process

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.