Home

Comprehension

Comprehension List Comprehension: # Basic list comprehension new_list = [expression for item in iterable if condition] # Example: numbers = [1, 2, 3, 4, 5] squared = [x**2 for x in numbers if x % 2 == 0] # squares of even numbers Set Comprehension: # Basic set comprehension new_set = {expression for item in iterable if condition} # Examp...

Read more

Python Magic methods

Python Magic methods Initialization and Representation __init__(self, ...): Object constructor, initializes the object. __del__(self): Object destructor, called when the object is about to be destroyed. __repr__(self): Defines the "official" string representation of an object, used by repr() and in debugging. __str__(self): Defines the "inform...

Read more

cache

cache LRUCache (Least Recently Used Cache) Eviction Policy: Evicts the least recently used items first when the cache reaches its maximum size. Usage: Useful when you want to keep the most recently accessed items in the cache. RRCache (Random Replacement Cache) Eviction Policy: Randomly evicts cache entries when the...

Read more

Java Memory Model

Java Memory Model Reference Java Memory Model: A Comprehensive Guide [Java memory model](https://en.wikipedia.org/wiki/Java_memory_model#:~:text=The%20Java%20Memory%20Model%20(JMM,consistent%20and%20reliable%20Java%20applications.) Java Memory Model in 10 minutes

Read more