Foundations 0/223

Foundations

Python classes and runtime

Class and instance state, dunder protocols, iterators and generators, decorators, context managers, typing, asyncio and how CPython manages memory. A class you write to a spec in Python leans on all of them.

0 / 66 solved

Questions

0/66 solved
Question Module Tags Difficulty Success
1. Where Attributes Actually Live Class & Instance State
dictclass-attributes +1
Medium —
2. Instance Dict Contents Class & Instance State
dictinstance-attributes +1
Medium —
3. Opting Out of Auto-Binding Class & Instance State
staticmethodclassmethod +2
Medium —
4. Self Is Just a Name Class & Instance State
selfbound-methods +1
Medium —
5. Bound Method or Plain Function Class & Instance State
bound-methodsdescriptors +1
Medium 40%
6. Which Ancestor Answers First Class & Instance State
mroattribute-lookup +2
Hard —
7. Reading Through, Writing Around Class & Instance State
attribute-assignmentclass-attributes +1
Hard —
8. Mutate Versus Reassign Class & Instance State
mutable-defaultclass-attributes +2
Hard 40%
9. Two Calling Conventions, Same Result Class & Instance State
bound-methodsself +1
Hard —
10. Overriding a Method Down the Chain Inheritance & Dunder Protocols
mroinheritance +1
Medium —
11. super() in Single Inheritance Inheritance & Dunder Protocols
superinheritance +1
Medium —
12. Diamond Inheritance MRO Order Inheritance & Dunder Protocols
mroc3-linearization +2
Medium —
13. Why Methods Bind Automatically Inheritance & Dunder Protocols
descriptor-protocolmethods +1
Medium —
14. Powering len() and in Without __contains__ Inheritance & Dunder Protocols
leniter +2
Medium —
15. A Read-Only property Still Blocks Writes Inheritance & Dunder Protocols
descriptor-protocolproperty +1
Hard 33%
16. Same Method, Different super() Target Inheritance & Dunder Protocols
supermro +2
Hard 60%
17. Data Descriptors Beat the Instance Dict Inheritance & Dunder Protocols
descriptor-protocoldata-descriptor +1
Hard —
18. repr, str, and eq Together Inheritance & Dunder Protocols
reprstr +2
Insane —
19. Has One Method, Not the Other Iterators & Generators
iteratorsiterables +1
Medium 57%
20. Reusable List, One-Shot Iterator Iterators & Generators
iteratorsiterables +1
Medium 44%
21. Advancing a Generator Expression Iterators & Generators
generatorsgenerator-expressions +1
Medium 57%
22. Enumerate and Zip Only Go Once Iterators & Generators
iteratorsenumerate +2
Medium —
23. Which Ones Are Already Iterators Iterators & Generators
iteratorsiterables +1
Medium 15%
24. Nothing Runs Until You Ask Iterators & Generators
generatorsyield +1
Medium 60%
25. Order of Nested For Clauses Iterators & Generators
comprehensionsnested-comprehensions +1
Medium —
26. Range Object vs Generator Object Iterators & Generators
iteratorsgenerators +2
Hard —
27. Delegating With Yield From Iterators & Generators
yield-fromgenerators +1
Hard 50%
28. When the Division Actually Happens Iterators & Generators
generator-expressionslist-comprehensions +1
Hard —
29. What the Comprehension Can See Iterators & Generators
comprehensionsscope +2
Insane 60%
30. First-Class Function References Decorators & Imports
first-class-functionscallables +1
Medium —
31. Wrapper Loses Its Name Decorators & Imports
decoratorsfunctools-wraps +1
Medium —
32. Decorator Line, Desugared Decorators & Imports
decoratorsdefinition-time +1
Medium 80%
33. Decoration Time vs Call Time Decorators & Imports
decoratorsclosures +1
Medium 60%
34. True Statements About Decorators Decorators & Imports
decoratorsfunctools-wraps +2
Medium 50%
35. Cached Import, Correct Main Guard Decorators & Imports
module-executionsys-modules +2
Hard 67%
36. From-Import Freezes a Value Decorators & Imports
importsname-binding +2
Hard 67%
37. Else and Finally Timing Exceptions & Context Managers
try-exceptelse-clause +2
Medium —
38. Explicit Cause Chaining Exceptions & Context Managers
exception-chainingraise-from +1
Medium 80%
39. Finally Return Overrides Try Exceptions & Context Managers
finallyreturn-override +1
Medium 44%
40. Cleanup Guarantee in contextmanager Exceptions & Context Managers
context-managercontextlib +2
Medium 50%
41. Propagation Past a Mismatched Except Exceptions & Context Managers
exception-propagationcustom-exceptions +2
Hard 50%
42. Exit Suppressing an Exception Exceptions & Context Managers
context-managerdunder-exit +1
Hard 50%
43. Finally Return Swallows an Exception Exceptions & Context Managers
finallyexception-suppression +1
Hard 44%
44. Implicit Exception Context Exceptions & Context Managers
exception-chainingimplicit-context +1
Hard 33%
45. Optional Means Union With None Typing & Performance
typingoptional +1
Medium —
46. Type Hints Are Not Enforced Typing & Performance
type-hintsruntime-behavior +1
Medium —
47. Set Membership Versus List Membership Typing & Performance
dictset +2
Medium —
48. Why Append Beats Concatenation Typing & Performance
listcomplexity +2
Medium —
49. Generator Memory Versus List Memory Typing & Performance
generatorlist-comprehension +2
Medium —
50. Three Ways To Match A Duck Typing & Performance
duck-typingprotocol +2
Hard —
51. String Concatenation Versus Join Typing & Performance
stringsimmutability +2
Hard —
52. Protocols Check Names Not Signatures Typing & Performance
type-hintsprotocol +2
Hard —
53. What the CPython GIL Actually Locks Concurrency & Async
gilcpython +1
Medium —
54. Total Wall-Clock Time of Concurrent Sleeps Concurrency & Async
asynciogather +2
Medium 80%
55. Threads for I/O-Bound Versus CPU-Bound Work Concurrency & Async
gilcpython +2
Medium —
56. Calling an async def Function Concurrency & Async
asynciocoroutines +1
Medium —
57. A Blocking Call Inside a Coroutine Concurrency & Async
asyncioevent-loop +2
Hard —
58. What asyncio.gather Actually Does Concurrency & Async
asynciogather +2
Hard —
59. A Counter Race Despite the GIL Concurrency & Async
gilcpython +2
Hard —
60. What Del Actually Deletes Memory & CPython Internals
reference-countingdel +1
Medium —
61. The Extra getrefcount Reference Memory & CPython Internals
reference-countingsys-getrefcount +2
Medium —
62. Refcount Zero and Reused Addresses Memory & CPython Internals
reference-countingid +2
Medium —
63. Interned Literals vs Runtime Strings Memory & CPython Internals
string-interningis-vs-equals +2
Medium —
64. CPython Memory Management Facts Memory & CPython Internals
reference-countinggarbage-collection +2
Medium —
65. The Small-Int Cache Boundary Memory & CPython Internals
small-int-cacheis-vs-equals +2
Hard 33%
66. Reference Counting Cannot Break Cycles Memory & CPython Internals
reference-cyclegarbage-collection +2
Hard —