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

  • Home
  • SEARCH
  • 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 9163533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:28:12+00:00 2026-06-17T14:28:12+00:00

I have a python list, which consists of 80000 lists. Each of these inner

  • 0

I have a python list, which consists of 80000 lists. Each of these inner lists more or less have this format:

["012345", "MYNAME" "Mon", "A", 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]

Could you tell approximately how much memory would this list consisting of 80000 lists consume?

And is it common/OK to use and operate on lists that big in python? Most of the operations I do is to extract data from this list with list comprehension method.

Actually, what I would like to learn is: is python fast enough to extract data from that big lists using list comprehension methods. I want my script to be fast

  • 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-17T14:28:13+00:00Added an answer on June 17, 2026 at 2:28 pm
    In [39]: lis=["012345", "MYNAME" "Mon", "A", 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
         20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]
    
    In [40]: k=[lis[:] for _ in xrange(80000)]
    
    In [41]: k.__sizeof__()
    Out[41]: 325664
    
    In [42]: sys.getsizeof(k)  #after gc_head
    Out[42]: 325676
    

    As per the code in sysmodule.c it looks like it calls __sizeof__ method to get the size of an object.

       837   method = _PyObject_LookupSpecial(o, &PyId___sizeof__);   
       838     if (method == NULL) {
       839         if (!PyErr_Occurred())
       840             PyErr_Format(PyExc_TypeError,
       841                          "Type %.100s doesn't define __sizeof__",
       842                          Py_TYPE(o)->tp_name);
       843     }
       844     else {
       845         res = PyObject_CallFunctionObjArgs(method, NULL);
       846         Py_DECREF(method);
       847     }
    

    and then adds some gc overhead to it:

       860     /* add gc_head size */
       861     if (PyObject_IS_GC(o)) {
       862         PyObject *tmp = res;
       863         res = PyNumber_Add(tmp, gc_head_size);
       864         Py_DECREF(tmp);
       865     }
       866     return res;
       867 }
    

    We can also use the recursive sizeof recipe as suggested in docs to recursively calculate the size of each container:

    In [17]: total_size(k)  #from recursive sizeof recipe
    Out[17]: 13125767
    
    In [18]: sum(y.__sizeof__() for x in k for y in x)
    Out[18]: 34160000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list which is in this certain format. [u' ', u'Address :',u'Sadar
I have a python list which looks a little like this: [[0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,90,1,9999,0,0,0,0,0,0,0,00,0], [0,0,0,0,0,0,0,0,0,0,0,0,00,0],[0,0,90,1,9999,1,2,0,0,9999,0,0,00,0].....till about
I have a JSON/Python nested list which represents a tree, each item being a
I have a python list which contains dictionaries and I want to make a
I have list in python which has following entries name-1 name-2 name-3 name-4 name-1
I have a list which I have obtained from a python script. the content
I have a (python) list of strings which refer to python source files and
I have a Python list with a number of entries, which I need to
I have a list which I shuffle with the Python built in shuffle function
I have a python list which holds a few email ids accepted as unicode

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.