All fields

“functools & Functional Programming Tools” in Information Technology

27 questions across 1 technology.

Information Technology

27 questions in 1 technology

#QuestionTechnologyTopicLevel
1What is the difference between functools.cache and functools.lru_cache? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsBeginner
2What is the functools module used for in Python? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsBeginner
3How do you use functools.partial to fix keyword arguments for logging or callback functions? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsBeginner
4How does functools.partial work and when is it useful? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
5What does functools.reduce do, and why is it often discouraged in favor of loops? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
6How does @functools.wraps preserve metadata when writing decorators? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
7How does functools.total_ordering reduce boilerplate for comparison methods? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
8What does functools.reduce's initializer argument do, and why should you usually provide one? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
9What is the practical difference between using functools.reduce and a plain for-loop for accumulation? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
10How does functools.singledispatch enable function overloading based on argument type? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsAdvanced
11What is functools.cached_property and how does it differ from @property combined with manual caching? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsAdvanced
12How does functools.cmp_to_key bridge old-style comparison functions with Python 3's key-based sorting? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsAdvanced
13How can functools.lru_cache be used with typed=True, and what does that change? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsAdvanced
14How do you clear or inspect the cache of an lru_cache-decorated function? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsAdvanced
15Why is caution needed when applying @lru_cache directly to instance methods? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsAdvanced
16Why should you use functools.wraps when writing a decorator, and what problem does it solve? Python › DecoratorsPythonDecoratorsIntermediate
17How do you use functools.lru_cache to add memoization to a function with a single decorator? Python › DecoratorsPythonDecoratorsIntermediate
18How do you use functools.partial to create a new function with some arguments pre-filled? Python › Functions & ScopePythonFunctions & ScopeAdvanced
19How does the itertools module complement the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
20How does itertools.tee let you iterate over the same iterator multiple times independently? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
21How do you write an async context manager more concisely using @contextlib.asynccontextmanager? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersIntermediate
22How does the 'nonlocal' keyword let a nested function modify a variable in its ENCLOSING (not global) scope? Python › Functions & ScopePythonFunctions & ScopeIntermediate
23How do comparison magic methods like __lt__, __le__, __gt__, and __ge__ support custom sorting? Python › Magic Methods & Operator OverloadingPythonMagic Methods & Operator OverloadingIntermediate
24How would you implement a memory-efficient sliding window or batching generator over a large iterable? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
25How would you use concurrent.futures.ProcessPoolExecutor together with asyncio to run CPU-bound work without blocking the event loop? Python › Concurrency (asyncio/threading/multiprocessing)PythonConcurrency (asyncio/threading/multiprocessing)Advanced
26How would you efficiently merge two dictionaries in modern Python, and how do the different approaches handle overlapping keys? Python › Data Types & StructuresPythonData Types & StructuresAdvanced
27How does Python evaluate default argument expressions ONLY ONCE at definition time, and what SAFE pattern exploits this for genuinely useful caching? Python › Functions & ScopePythonFunctions & ScopeAdvanced