Questions tagged [dictionary]
The dictionary tag has no summary.
62 questions
0 votes
1 answer
158 views
Optimal way to avoid iterating through each row in a dictionary of data/arrays?
I have an excel macro that imports daily share price files, and finds the highest price for a share after a given date. Each of these daily stock price files has ~1000 rows of data. Currently I have ...
1 vote
1 answer
114 views
Python: mapping the content of a structured text file to dictionary tree
I'm looking for a method to map the content of a structured text file to a nested dictionary (dictionary tree). The text file consists of (nested) sections with each section starting with the pattern ...
3 votes
5 answers
2k views
C# List vs Dictionary cost vs benefit with complex keys
I am designing a program and I am looking to decide over a Dictionary vs a List. Since I know I have unique values per item I imagined a Dictionary/List that looks like: Dictionary<(int k1, string ...
1 vote
1 answer
139 views
Long dictionary/map key vs shorter key + equality check for an auth cache
I'm implementing an API key based authentication scheme and I'm caching valid API key entries (hash, scope etc.) in a memory cache. For the cache key, I had been using the first 8 characters of the ...
1 vote
1 answer
104 views
How to reuse parts of a Trie data structure (like a Trie DAG)?
I am playing around with a cross-language spell-check sort of thing, and am still in the prototyping/ideation phases. Basically I have thought of something like a Trie data structure, but I keep ...
7 votes
1 answer
3k views
Why are there two ways to retrieve values from a dictionary in Python?
In Python there are basically two ways to get a value from a dictionary: dictionary["key"] dictionary.get("key") Is there any - maybe historical - reason for this behavior? I ...
0 votes
0 answers
142 views
Is it a code smell to have to query a dictionary for a key whose value matches some criteria?
I am working on a ChildModelListSheetHandler, that has a childModelListDict. As what you're probably thinking, it maps the foreign keys that are the IDs of the parent models, to the list of child ...
2 votes
1 answer
869 views
Elegant way to handle two options, when both is also an option
In the simplest case, I have some code where the user may want to do one thing (a), another thing, (b), or both (a+b). The options are reasonably complex and have their own functions, but I would like ...
0 votes
1 answer
2k views
Query language for python dictionary
I have a list of python dictionaries (let's assume each dict is flat for the time being). The keys are all strings and the values are strings or real numbers. I would like the user to have the freedom ...
1 vote
2 answers
2k views
Why it is possible to specify a value comparer for ImmutableDictionary<TKey, TValue>?
What is the intended usage of the ImmutableDictionary<TKey,TValue>.ValueComparer property? Why is it useful being able to compare dictionary values by using a specified equality semantic? I ...
-4 votes
4 answers
3k views
Time efficient way to count pairs in an array whose sum is divisible by a specific number?
Given an array of integers, we want to find how many explicit pairs can be made such that their sum is divisible by 60. The pairs are not necessarily non-unique. For example, let's say the input into ...
0 votes
1 answer
3k views
What is the space complexity of a Python dictionary?
If python dictionaries are essentially hash tables and the length of hashes used in the python dictionary implementation is 32 bits, that would mean that regardless of the number of key-value pairs ...
-2 votes
1 answer
88 views
Find circular references of first order (bi-directional referencing)
I have million of objects, each with an array smaller than 10 elements, which are the names of other objects in the dataset. Basically { a:[b,c,d,], b:[c,d,e], c:[a,e,f], ... e:[a,b,c] } will ...
0 votes
1 answer
2k views
Unpacking python dictionaries, or list comprehension, or …
my_dict = { 1: 11, 2: 12, 3: 13 } If I want to work on the list of keys from my_dict there appear to be (at least) three ways to do this in Python >3.5 (i.e. on or after PEP 448) List Comprehension: ...
1 vote
3 answers
557 views
Are 'array elements' and 'array values' the same?
Array := {"title": "Book Title", "author": "John Doe"} Some people use the following terminology: title and author are keys. Book Title and John Doe are values. "title": "Book Title" and "author": "...