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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:40:12+00:00 2026-06-03T01:40:12+00:00

For example, if I have got millions of records inside a dictionary with the

  • 0

For example, if I have got millions of records inside a dictionary with the form of
{(1,2):3,(2,3):4,(3:2):5...xmillion}
That’s a tuple as a key and with a corresponding value

What I would like to do is get the data of which the value of tuple[1] = 2
One of my approach is

    for item, value in dict.iteritems():
      if item[1] == 2:
        Do operations here...

This is a slow approach, is there a better algorithm for doing this to make it fast?
Like.. so I don’t have to go through million of the items

  • 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-03T01:40:14+00:00Added an answer on June 3, 2026 at 1:40 am

    In a dictionary of tuples as key, you would have to iterate through all the keys to find
    those with key[1] == 2. There is no other alternative to solving the problem.

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

Sidebar

Related Questions

Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I
I have a form in that i am getting the initial value of form
I have got an example here: http://jsfiddle.net/cByhZ/ As you can see the buttons value
GridView CurrentGrid =Grd_UserList; Grd_UserList.Columns.Clear(); ı have got this example, ı use Columns.Clear(); fonc. with
I got trouble on Member Description show up. For example, I have two laptops.
We have got an extjs 3.1.1 form with file upload field ( http://www.extjs.com/deploy/dev/examples/form/file-upload.html from
Why does: const char example; (uint64*)example have a value of 140734799798420 and *(uint64*)example have
Example: I have an class that inherits from UIImageView. An object creates an instance
I have got a file which is let's say 8 bytes length. For example
how to use LIKE in CASE statement, I have got this example script but

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.