is hash map data structure available in Python?

G

grbgooglefan

Hi,
I have a situation that I need to search a name in a big list of names
in my Python embedded interpreter. I am planning to use hash map for
quicker search.
How do I create hash map in Python?
Can you please guide me to some documentation or tutorial which
provides information on creating, editing, searching through hash map
in Python?
Thanks.
 
S

sturlamolden

How do I create hash map in Python?

Python dictionaries are the fastest hash maps known to man.

If you need persistent storage of your hash map, consider module bsddb
or dbhash.
 
T

Terry Reedy

|
| > How do I create hash map in Python?
|
| Python dictionaries are the fastest hash maps known to man.

If you only have keys (the names) and no values attached to them, then use
a set.
 
7

7stud

Hi,
I have a situation that I need to search a name in a big list of names
in my Python embedded interpreter. I am planning to use hash map for
quicker search.
How do I create hash map in Python?
Can you please guide me to some documentation or tutorial which
provides information on creating, editing, searching through hash map
in Python?
Thanks.

#creating:
my_dict = {'a':1, 'b':2, 'c':3}

#editing:
my_dict['a'] = 10

#searching:
result = my_dict.get('a', None)
print result //10

result = my_dict.get('f', None)
print result //None
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top