Python and data for quants
You test x in container millions of times against a fixed collection of 100,000 ids.
FoundationMultiple choice
You test x in container millions of times against a fixed collection of 100,000 ids. Which container should you use?
- AA list, since it preserves the original order of the ids
- BA set
- CA tuple, because it is immutable and therefore faster
- DA sorted list with
in, which uses binary search automatically
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Report an issue with this question
Learn the method
Performance: profiling, vectorising and when to leave Python
Of the kind reported at
More python and data for quants questions
- Profiling shows 60% of runtime in one function.Applied · Premium
- A rolling mean, faster, part 2 of 3Applied · Premium
- A NumPy array is C-ordered. Which loop is faster: summing along rows or along columns?Advanced · Premium
- A rolling mean, faster, part 3 of 3Expert · Premium
- A rolling mean, faster, part 1 of 3Foundation · Premium
- A backtest computes pnl = signal * returns, where both are indexed by day. What is wrong?Applied · Free solution