원클릭으로
intern-symbols-identity
For fast comparison: ensure only one instance of each symbol, use 'is' instead of '==', symbol tables for interpreters.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
For fast comparison: ensure only one instance of each symbol, use 'is' instead of '==', symbol tables for interpreters.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Conducts iterative deep research on any topic using web search, progressive exploration, and structured synthesis. Use when asked for comprehensive research, deep investigation, thorough analysis, or multi-source exploration of any topic. Triggers: research, investigate, deep dive, comprehensive analysis, explore thoroughly, find everything about.
For cross-cutting concerns: add behavior without modifying functions, caching, timing, logging, validation wrappers.
For performance work: measure before changing, profile to find bottlenecks, compare before and after.
For symbolic computation: ASTs, mathematical expressions, code that manipulates code structure, expression transformations.
For ordered processing: A* search, Dijkstra, event simulation, task scheduling. Efficient min/max extraction with heap-based queue.
For dynamic programming: overlapping subproblems, recursive solutions with repeated computations, memoization to avoid redundant work.
| name | intern-symbols-identity |
| description | For fast comparison: ensure only one instance of each symbol, use 'is' instead of '==', symbol tables for interpreters. |
is vs ==)Use a table to ensure each unique symbol exists only once.
class Symbol(str):
"""A symbol is a unique string."""
pass
def Sym(s, symbol_table={}):
"""Return the unique Symbol for string s."""
if s not in symbol_table:
symbol_table[s] = Symbol(s)
return symbol_table[s]
# Now identity comparison works
quote = Sym('quote')
assert Sym('quote') is quote # Same object!
assert Sym('quote') is Sym('quote') # Always same object
# Fast dispatch with 'is'
if x[0] is quote: # Faster than x[0] == 'quote'
return handle_quote(x)
class Symbol(str):
"""A Lisp Symbol is implemented as a Python str subclass."""
pass
def Sym(s, symbol_table={}):
"""Find or create unique Symbol entry for str s in symbol table."""
if s not in symbol_table:
symbol_table[s] = Symbol(s)
return symbol_table[s]
# Pre-intern common symbols
_quote, _if, _set, _define, _lambda, _begin, _definemacro = map(Sym,
"quote if set! define lambda begin define-macro".split())
_quasiquote, _unquote, _unquotesplicing = map(Sym,
"quasiquote unquote unquote-splicing".split())
# Fast dispatch in eval using 'is'
def eval(x, env=global_env):
if isinstance(x, Symbol):
return env.find(x)[x]
elif not isinstance(x, list):
return x
elif x[0] is _quote: # Fast identity check
return x[1]
elif x[0] is _if: # Fast identity check
(_, test, conseq, alt) = x
return eval(conseq if eval(test, env) else alt, env)
elif x[0] is _define: # Fast identity check
(_, var, exp) = x
env[var] = eval(exp, env)
# ... more special forms
# Note: Using 'is' instead of '==' because symbols are interned
symbol_table={} persistsis for dispatch: Faster than string comparisonSym()