Python Forum
Dictionaries and memory error.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionaries and memory error.
#1
Is there a limit on how big a dictionary can be? I am trying to make one of all permutations of 0-9. If I do 0-8 it works fine. If I do 0-9 it gives a long pause them a Memory Error. How do I know what the limit is?

Is there another way to store this? a list was taking way way too long.
Reply
#2
why do you want to store all the possible permutations in memory? that is inefficient
Reply
#3
(Feb-23-2018, 11:48 AM)buran Wrote: why do you want to store all the possible permutations in memory? that is inefficient

So what is the efficient way to be able to try all possible permutations for a variable until you get one that meets the criteria?
Reply
#4
use itertools.permutations(). Create iterator, consume it one permutation at a time to work with
this is brute force, so may be slow. there may be more efficient way to solve your problem (we don't know what your problem is)
Reply
#5
(Feb-23-2018, 12:06 PM)buran Wrote: use itertools.permutations(). Create iterator, consume it one permutation at a time to work with
this is brute force, so may be slow. there may be more efficient way to solve your problem (we don't know what your problem is)

I seemed to have fixed my issue. I tried to create a list in program to store all the permutations but it was just taking forever. Almost instant now. Must have made a bug somewhere.

Anyways, it would be nice to know how to get itertools to feed the permutations into a variable one at a time. How do I do that?
Reply
#6
import itertools
for perm in itertools.permutations(range(5), 3):
    print(perm)
this will print all permutations with length 3 for numbers 0-4
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Understanding and debugging memory error crashes with python3.10.10 Arkaik 5 1,978 Apr-18-2023, 03:22 AM
Last Post: Larz60+
  Memory Error While generating cheksum no mg24 2 984 Sep-25-2022, 10:33 PM
Last Post: mg24
  Gui slot machine-out of memory error steve_shambles 12 4,990 May-18-2020, 11:31 PM
Last Post: deanhystad
  Go around memory error Pytonormen 1 2,039 Oct-19-2019, 04:31 PM
Last Post: Gribouillis
  memory error using permutation list of 11 elements kikidog 1 3,847 Sep-10-2019, 08:22 PM
Last Post: ichabod801
  Fix Memory Error while installing a library for Qgis alexastorga 0 2,557 Apr-13-2018, 04:54 PM
Last Post: alexastorga

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020