text
stringlengths 0
828
|
---|
'STORE_ATTR': -2,
|
'DELETE_ATTR': -1,
|
'STORE_GLOBAL': -1,
|
'DELETE_GLOBAL': 0,
|
'LOAD_CONST': 1,
|
'LOAD_NAME': 1,
|
'BUILD_TUPLE': lambda op: 1 - op.arg,
|
'BUILD_LIST': lambda op: 1 - op.arg,
|
'BUILD_SET': lambda op: 1 - op.arg,
|
'BUILD_MAP': lambda op: 1 - op.arg,
|
'LOAD_ATTR': 0,
|
'COMPARE_OP': 1, # xxx: check
|
# 'IMPORT_NAME':
|
# 'IMPORT_FROM':
|
# 'JUMP_FORWARD':
|
# 'POP_JUMP_IF_TRUE':
|
# 'POP_JUMP_IF_FALSE':
|
# 'JUMP_IF_TRUE_OR_POP':
|
# 'JUMP_IF_FALSE_OR_POP':
|
# 'JUMP_ABSOLUTE':
|
# 'FOR_ITER':
|
'LOAD_GLOBAL': 1,
|
# 'SETUP_LOOP'
|
# 'SETUP_EXCEPT'
|
# 'SETUP_FINALLY':
|
'LOAD_FAST': 1,
|
'STORE_FAST': -1,
|
'DELETE_FAST': 0,
|
# 'LOAD_CLOSURE':
|
'LOAD_DEREF': 1,
|
'LOAD_CLASSDEREF': 1,
|
'STORE_DEREF': -1,
|
'DELETE_DEREF': 0,
|
'RAISE_VARARGS': lambda op: -op.arg,
|
'CALL_FUNCTION': lambda op: 1 - _call_function_argc(op.arg),
|
'MAKE_FUNCTION': lambda op: 1 - _make_function_argc(op.arg),
|
# 'MAKE_CLOSURE':
|
'BUILD_SLICE': lambda op: 1 - op.arg,
|
# 'EXTENDED_ARG':
|
'CALL_FUNCTION_KW': lambda op: 1 - _call_function_argc(op.arg),
|
}
|
if sys.version >= '3.5':
|
result.update({
|
'BEFORE_ASYNC_WITH': 0,
|
'SETUP_ASYNC_WITH': 0,
|
# Coroutine operations
|
'GET_YIELD_FROM_ITER': 0,
|
'GET_AWAITABLE': 0,
|
'GET_AITER': 0,
|
'GET_ANEXT': 0,
|
})
|
if sys.version <= '3.5':
|
result.update({
|
'CALL_FUNCTION_VAR': lambda op: 1 - _call_function_argc(op.arg),
|
'CALL_FUNCTION_VAR_KW': lambda op: 1 - _call_function_argc(op.arg),
|
})
|
for code in dis.opmap.keys():
|
if code.startswith('UNARY_'):
|
result[code] = 0
|
elif code.startswith('BINARY_') or code.startswith('INPLACE_'):
|
result[code] = -1
|
return result"
|
265,"def get_stackdelta(op):
|
""""""
|
Returns the number of elements that the instruction *op* adds to the stack.
|
# Arguments
|
op (dis.Instruction): The instruction to retrieve the stackdelta value for.
|
# Raises
|
KeyError: If the instruction *op* is not supported.
|
""""""
|
res = opstackd[op.opname]
|
if callable(res):
|
res = res(op)
|
return res"
|
266,"def get_assigned_name(frame):
|
""""""
|
Checks the bytecode of *frame* to find the name of the variable a result is
|
being assigned to and returns that name. Returns the full left operand of the
|
assignment. Raises a #ValueError if the variable name could not be retrieved
|
from the bytecode (eg. if an unpack sequence is on the left side of the
|
assignment).
|
> **Known Limitations**: The expression in the *frame* from which this
|
> function is called must be the first part of that expression. For
|
> example, `foo = [get_assigned_name(get_frame())] + [42]` works,
|
> but `foo = [42, get_assigned_name(get_frame())]` does not!
|
```python
|
>>> var = get_assigned_name(sys._getframe())
|
>>> assert var == 'var'
|
```
|
__Available in Python 3.4, 3.5__
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.