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

Android View

Android View 双缓存: 屏幕缓存和GPS渲染缓存分开, 防止屏幕显示不完整的帧 Back Buffer和Frame Buffer VSync: Vertical Synchronization, 利用Vertical Blanking Interval(VBI) 间隙的 vertical sync pulse(垂直同步脉冲)交换双缓存. 避免screen tearing. Choreographer: 保证绘制拥有完整的16.6ms,避免绘制的随机性 SurfaceFlinger: 接受多个来源的图形显示数据,将他们合成,然后发送到显示设备进行渲染 重绘 requestLayout 或者 invalidate performTravers...

Read more