docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
---
|
||||
id: wiki-2026-0508-iteration
|
||||
title: Iteration
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Iterative Development, Loop, Iterate]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [methodology, agile, python, control-flow, generators]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: general
|
||||
---
|
||||
|
||||
# Iteration
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 small step, 매 feedback, 매 adjust, 매 repeat"**. Iteration 매 dual concept — (1) programming control flow (`for`, `while`, generators) 와 (2) development methodology (small increments + feedback loop). 2026 LLM-assisted 시대 매 iteration 매 even tighter — 매 minute 매 cycle 가능.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 Programming iteration
|
||||
- **Eager**: `for x in list` — 매 list 매 fully materialized.
|
||||
- **Lazy**: generator, iterator — 매 on-demand pull.
|
||||
- **Async**: `async for x in stream` — 매 I/O 의 overlap.
|
||||
- **Parallel**: `joblib`, `multiprocessing.Pool.imap` — 매 CPU-bound iteration.
|
||||
|
||||
### 매 Methodology iteration
|
||||
- **Loop**: hypothesis → build → measure → learn.
|
||||
- **Cadence**: daily (LLM-assisted), weekly (sprint), monthly (release).
|
||||
- **Artifact per cycle**: shippable increment.
|
||||
- **Feedback source**: tests, users, metrics, code review.
|
||||
|
||||
### 매 응용
|
||||
1. Data pipeline (process N rows lazily).
|
||||
2. ML hyperparameter search (iteratively narrow).
|
||||
3. Agile sprint (2-week cycle).
|
||||
4. LLM agentic loop (think → act → observe → repeat).
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Pattern 1: Generator (lazy iteration)
|
||||
```python
|
||||
def read_jsonl(path: str):
|
||||
"""매 1GB+ file 의 stream — 매 memory O(1)."""
|
||||
import json
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
yield json.loads(line)
|
||||
|
||||
for record in read_jsonl("events.jsonl"):
|
||||
process(record)
|
||||
```
|
||||
|
||||
### Pattern 2: Itertools combinators
|
||||
```python
|
||||
from itertools import islice, chain, groupby, accumulate
|
||||
|
||||
# 매 first 100 records 만
|
||||
head = list(islice(read_jsonl("big.jsonl"), 100))
|
||||
|
||||
# 매 multiple sources 의 concat
|
||||
combined = chain(read_jsonl("a.jsonl"), read_jsonl("b.jsonl"))
|
||||
|
||||
# 매 group by user
|
||||
sorted_records = sorted(combined, key=lambda r: r["user_id"])
|
||||
for user_id, group in groupby(sorted_records, key=lambda r: r["user_id"]):
|
||||
handle_user(user_id, list(group))
|
||||
```
|
||||
|
||||
### Pattern 3: Async iteration (2026)
|
||||
```python
|
||||
import asyncio
|
||||
import httpx
|
||||
|
||||
async def fetch_pages(urls: list[str]):
|
||||
async with httpx.AsyncClient() as client:
|
||||
async def fetch(url):
|
||||
r = await client.get(url)
|
||||
return url, r.text
|
||||
for coro in asyncio.as_completed([fetch(u) for u in urls]):
|
||||
yield await coro
|
||||
|
||||
async def main():
|
||||
async for url, html in fetch_pages(URLS):
|
||||
print(url, len(html))
|
||||
```
|
||||
|
||||
### Pattern 4: Iterative refinement (algorithm)
|
||||
```python
|
||||
def newton_sqrt(n: float, tol: float = 1e-10, max_iter: int = 50) -> float:
|
||||
x = n / 2
|
||||
for _ in range(max_iter):
|
||||
x_new = 0.5 * (x + n / x)
|
||||
if abs(x_new - x) < tol:
|
||||
return x_new
|
||||
x = x_new
|
||||
return x
|
||||
```
|
||||
|
||||
### Pattern 5: LLM agentic loop (2026)
|
||||
```python
|
||||
from anthropic import Anthropic
|
||||
|
||||
client = Anthropic()
|
||||
|
||||
def agent_loop(task: str, max_iter: int = 10):
|
||||
history = [{"role": "user", "content": task}]
|
||||
for i in range(max_iter):
|
||||
msg = client.messages.create(
|
||||
model="claude-opus-4-7",
|
||||
max_tokens=4000,
|
||||
tools=TOOLS,
|
||||
messages=history,
|
||||
)
|
||||
history.append({"role": "assistant", "content": msg.content})
|
||||
if msg.stop_reason == "end_turn":
|
||||
return msg
|
||||
# tool_use → execute → observation → next iter
|
||||
observations = execute_tools(msg.content)
|
||||
history.append({"role": "user", "content": observations})
|
||||
raise RuntimeError("매 max_iter 의 reach")
|
||||
```
|
||||
|
||||
### Pattern 6: Sprint retrospective
|
||||
```python
|
||||
def retro(sprint_data: dict) -> dict:
|
||||
return {
|
||||
"what_worked": sprint_data["green_items"],
|
||||
"what_didnt": sprint_data["red_items"],
|
||||
"experiments_next": [
|
||||
f"Try {hypothesis}" for hypothesis in sprint_data["new_ideas"]
|
||||
],
|
||||
"metrics_delta": {
|
||||
k: sprint_data["after"][k] - sprint_data["before"][k]
|
||||
for k in sprint_data["before"]
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### Pattern 7: Bounded iteration with timeout
|
||||
```python
|
||||
import time
|
||||
|
||||
def iterate_with_budget(items, budget_sec: float):
|
||||
start = time.time()
|
||||
for item in items:
|
||||
if time.time() - start > budget_sec:
|
||||
print(f"매 budget 매 expire — {item} 의 stop")
|
||||
return
|
||||
yield process(item)
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Large file processing | Generator (lazy). |
|
||||
| Multiple I/O calls | Async iteration. |
|
||||
| CPU-bound loop | `multiprocessing` 또는 vectorize. |
|
||||
| Numerical convergence | While + tolerance check. |
|
||||
| Product development | 2-week sprint + retrospective. |
|
||||
| LLM agent | think-act-observe loop with max_iter cap. |
|
||||
|
||||
**기본값**: Programming 매 generator-first; methodology 매 1-week iteration with measurable hypothesis.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Agile]]
|
||||
- 응용: [[Generator]] · [[Sprint]]
|
||||
- Adjacent: [[Lean Startup]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: Agentic systems (think-act-observe), iterative refinement of code via LLM feedback, sprint planning summaries.
|
||||
**언제 X**: Single-shot generation, tasks where each iteration is 1+ hours of human work (cycle too slow).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Eager when lazy works**: `list(huge_generator)` — 매 OOM.
|
||||
- **Unbounded loop**: no max_iter — 매 infinite loop bug.
|
||||
- **No feedback in iteration**: 매 build without measure — methodology 매 broken.
|
||||
- **Perfect first iteration**: 매 ship at 70% — feedback 의 wait.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified: PEP 234 (iterators), Eric Ries "Lean Startup" (2011), "Continuous Delivery" (Humble & Farley).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — full content covering both programming and methodology iteration with LLM agentic loop |
|
||||
Reference in New Issue
Block a user