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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:36:01+00:00 2026-05-30T11:36:01+00:00

I ran several times an application with different input parameters in order to collect

  • 0

I ran several times an application with different input parameters in order to collect execution times.

The input parameters are 6: v, n, m, b, p and c.

Conceptually I can think of my results as a multidimensional array, where any dimension is a different parameter: times[A][B][C][D][E][F] would contain the execution time of the simulation using parameters v=A, n=B, m=C, b=D, p=E and c=F.

I’d like to be able to fix some of these parameters and iterate over the others:

for A:
  for C:
    for F:
      times[A][0][C][0][0][F]

The input parameters values are sparse, so I should use dictionaries instead of lists.

I was thinking about using a dict of dict of dict of dict of dict of dict to do the whole thing, each execution time would be represented like this:

times = { A:{ B:{ C:{ D:{ E:{ F:{time} } } } } } }

but this solution doesn’t look elegant at all: building the whole structure and iterating over it is a pain.

Is there any better way to work with my data?

  • 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-30T11:36:02+00:00Added an answer on May 30, 2026 at 11:36 am

    First, if you have to use a dictionary, why not just create a single dictionary, using tuples to index it? Second, use itertools.product to avoid troublesome nested loops:

    >>> import itertools
    >>> d = {}
    >>> for tup in itertools.product(range(5), repeat=2):
    ...     d[tup] = tup
    ... 
    >>> d
    {(1, 3): (1, 3), (3, 0): (3, 0), (2, 1): (2, 1), (0, 3): (0, 3), (4, 0): (4, 0), 
     (1, 2): (1, 2), (3, 3): (3, 3), (4, 4): (4, 4), (2, 2): (2, 2), (4, 1): (4, 1), 
     (1, 1): (1, 1), (3, 2): (3, 2), (0, 0): (0, 0), (0, 4): (0, 4), (1, 4): (1, 4), 
     (2, 3): (2, 3), (4, 2): (4, 2), (1, 0): (1, 0), (0, 1): (0, 1), (3, 1): (3, 1), 
     (2, 4): (2, 4), (2, 0): (2, 0), (4, 3): (4, 3), (3, 4): (3, 4), (0, 2): (0, 2)}
    

    However, there might be better ways to create a sparse array. scipy provides sparse matrices, but they are 2-d only, I believe.

    Here are some other usage patterns you might find useful:

    >>> for tup in itertools.product(range(5), repeat=2):
    ...     if tup[0] == tup[1]:
    ...         d[tup] = tup
    ... 
    >>> d
    {(3, 3): (3, 3), (0, 0): (0, 0), (1, 1): (1, 1), (4, 4): (4, 4), (2, 2): (2, 2)}
    
    >>> for tup in itertools.product(range(5), range(2)):
    ...     print d.get(tup)
    ... 
    (0, 0)
    None
    None
    (1, 1)
    None
    None
    None
    None
    None
    None
    

    To be less oblique, here’s how you would hold one variable constant: just pass a one-item sequence to itertools.product:

    >>> for tup in itertools.product(range(3), [2], range(3)):
    ...     print tup
    ... 
    (0, 2, 0)
    (0, 2, 1)
    (0, 2, 2)
    (1, 2, 0)
    (1, 2, 1)
    (1, 2, 2)
    (2, 2, 0)
    (2, 2, 1)
    (2, 2, 2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During the course of our application login there are several queries ran, all around
I have several times ran into the same problem, and I would like to
I have an application that may be run several times a day. Each run
I have tried on two different machines, and tried the download several times, but
I've ran through several examples over the web, and found that every single time
I recently ran across several objects implemented to handle events with a hard coded
I ran cprofile on a bit of code, which among other things spawns several
I have in an HTML page, an element that appears several times, and running
I'm experimenting with BitTornado-0.3.17 to distribute a file to several machines (*nix). I ran
In my iPhone app I would like to run several queries when the application

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.