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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:06:10+00:00 2026-05-13T09:06:10+00:00

If I have a list(or array, dictionary….) in python that could exceed the available

  • 0

If I have a list(or array, dictionary….) in python that could exceed the available memory address space, (32 bit python) what are the options and there relative speeds? (other than not making a list that large)
The list could exceed the memory but I have no way of knowing before hand. Once it starts exceeding 75% I would like to no longer keep the list in memory (or the new items anyway), is there a way to convert to a file based approach mid-stream?

What are the best (speed in and out) file storage options?

Just need to store a simple list of numbers. no need to random Nth element access, just append/pop type operations.

  • 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-05-13T09:06:11+00:00Added an answer on May 13, 2026 at 9:06 am

    If your “numbers” are simple-enough ones (signed or unsigned integers of up to 4 bytes each, or floats of 4 or 8 bytes each), I recommend the standard library array module as the best way to keep a few millions of them in memory (the “tip” of your “virtual array”) with a binary file (open for binary R/W) backing the rest of the structure on disk. array.array has very fast fromfile and tofile methods to facilitate the moving of data back and forth.

    I.e., basically, assuming for example unsigned-long numbers, something like:

    import os
    
    # no more than 100 million items in memory at a time
    MAXINMEM = int(1e8)
    
    class bigarray(object):
      def __init__(self):
        self.f = open('afile.dat', 'w+')
        self.a = array.array('L')
      def append(self, n):
        self.a.append(n)
        if len(self.a) > MAXINMEM:
          self.a.tofile(self.f)
          del self.a[:]
      def pop(self):
        if not len(self.a):
          try: self.f.seek(-self.a.itemsize * MAXINMEM, os.SEEK_END)
          except IOError: return self.a.pop()  # ensure normal IndexError &c
          try: self.a.fromfile(self.f, MAXINMEM)
          except EOFError: pass
          self.f.seek(-self.a.itemsize * MAXINMEM, os.SEEK_END)
          self.f.truncate()
        return self.a.pop()
    

    Of course you can add other methods as necessary (e.g. keep track of the overall length, add extend, whatever), but if pop and append are indeed all you need this should serve.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A TDBComboBox doesn't get its list of values from the… May 16, 2026 at 12:26 pm
  • Editorial Team
    Editorial Team added an answer It looks like it's supposed to be $('form').manualSubmit();, but this:… May 16, 2026 at 12:26 pm
  • Editorial Team
    Editorial Team added an answer Alternative, this could be achieved using the JXLayer project. Take… May 16, 2026 at 12:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an 'dictionary' array such as this: $arr['a']=5; $arr['b']=9; $arr['as']=56; $arr['gbsdfg']=89; And I
I have a class that has an internal list of other objects like so:
I have a Dictionary<string, List<Order>> and I want to have the list of keys
I have a list string tag. I am trying to initialize a dictionary with
What would be the best way to create an array that can have an
I have a list (cell array) of elements with structs like this: mystruct =
I have a dictionary whose keys are strings and values are numpy arrays, e.g.:
I have a Dictionary(TKey, TValue) like Dictionary<int, ArrayList> Deduction_Employees = new Dictionary<int, ArrayList>(); and
I have a list of objects and I need to find an object as
I currently have a list of a book object as follows: public class Book()

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.