You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Optimize Python 2/3 code2num
This commit is contained in:
@@ -11,6 +11,15 @@ import types
|
||||
import collections
|
||||
import io
|
||||
|
||||
from uncompyle6 import PYTHON3
|
||||
|
||||
if PYTHON3:
|
||||
def code2num(code, i):
|
||||
return code[i]
|
||||
else:
|
||||
def code2num(code, i):
|
||||
return ord(code[i])
|
||||
|
||||
_have_code = (types.MethodType, types.FunctionType, types.CodeType, type)
|
||||
|
||||
def _try_compile(source, name):
|
||||
@@ -314,11 +323,6 @@ def _get_name_info(name_index, name_list):
|
||||
argrepr = repr(argval)
|
||||
return argval, argrepr
|
||||
|
||||
|
||||
def code2num(code, i):
|
||||
op = code[i]
|
||||
return ord(op) if isinstance(op, str) else op
|
||||
|
||||
def _get_instructions_bytes(code, opnames, varnames=None, names=None, constants=None,
|
||||
cells=None, linestarts=None, line_offset=0):
|
||||
"""Iterate over the instructions in a bytecode string.
|
||||
|
Reference in New Issue
Block a user