如果您正在使用 Python 并且碰巧在这里结束,这就是查找表的样子。尽管如此,Bernd Elkemann 的 解释仍然成立。
# Generating the REVERSE_BIT_LUT while pre-processing
# LUT is shorthand for lookuptable
def R2(n, REVERSE_BIT_LUT):
REVERSE_BIT_LUT.extend([n, n + 2 * 64, n + 1 * 64, n + 3 * 64])
def R4(n, REVERSE_BIT_LUT):
return (
R2(n, REVERSE_BIT_LUT),
R2(n + 2 * 16, REVERSE_BIT_LUT),
R2(n + 1 * 16, REVERSE_BIT_LUT),
R2(n + 3 * 16, REVERSE_BIT_LUT),
)
def R6(n, REVERSE_BIT_LUT):
return (
R4(n, REVERSE_BIT_LUT),
R4(n + 2 * 4, REVERSE_BIT_LUT),
R4(n + 1 * 4, REVERSE_BIT_LUT),
R4(n + 3 * 4, REVERSE_BIT_LUT),
)
def LOOK_UP(REVERSE_BIT_LUT):
return (
R6(0, REVERSE_BIT_LUT),
R6(2, REVERSE_BIT_LUT),
R6(1, REVERSE_BIT_LUT),
R6(3, REVERSE_BIT_LUT),
)
# LOOK_UP is the function to generate the REVERSE_BIT_LUT
REVERSE_BIT_LUT = list()
LOOK_UP(REVERSE_BIT_LUT)
我正在努力在此处提供Sean在 Python中的小技巧的代码片段。