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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:07:14+00:00 2026-06-13T17:07:14+00:00

I know in python it’s hard to see the memory usage of an object.

  • 0

I know in python it’s hard to see the memory usage of an object.

Is it easier to do this for SciPy objects (for example, sparse matrix)?

  • 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-13T17:07:15+00:00Added an answer on June 13, 2026 at 5:07 pm

    you can use array.itemsize (size of the contained type in bytes) and array.flat to obtain the lenght:

    # a is your array
    bytes = a.itemsize * a.size
    

    it’s not the exact value, as it ignore the whole array infrastructure, but for big array it’s the value that matter (and I guess that you care because you have something big)

    if you want to use it on a sparse array you have to modify it, as the sparse doesn’t have the itemsize attribute. You have to access the dtype and get the itemsize from it:

    bytes = a.dtype.itemsize * a.size
    

    In general I don’t think it’s easy to evaluate the real memory occupied by a python object…the numpy array is an exception being just a thin layer over a C array

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

Sidebar

Related Questions

I have to really ask this question as I donot know Python. Following are
Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is
I know Python doesn't have pointers, but is there a way to have this
I know python functions are virtual by default. Let's say I have this: class
I know python can be run on GAE what is different erlang and python
I know Python (and a bunch of other languages) and I think it might
I don't know python and I'm porting a library to C#, I've encountered the
I am a novice programmer in (Java/C++/C#) and I also know Python. I am
I am a pretty good programmer(IMO only, of course. Know Python, Java well. Tried
I know that Python dict s will leak when items are removed (because the

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.