You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Learning:** Python`s `re.compile()` has some internal caching, but doing it in a tight loop across multiple text chunks or items still introduces measurable overhead.
3
3
**Action:** When a method applies dictionary/lexicon replacements via regular expressions, explicitly cache the compiled regex objects in a class attribute or closure, rather than compiling them on every call.
4
+
## 2024-05-24 - [String Concatenation Bottleneck]
5
+
**Learning:** Using `+=` for string concatenation inside loops (like iterating over PDF pages or large document segments) forces Python to create a new string object each time, leading to O(N²) time complexity.
6
+
**Action:** Always accumulate strings in a list using `.append()` and combine them once at the end using `"".join(list)` to maintain O(N) performance.
0 commit comments