Skip to content

Instantly share code, notes, and snippets.

@ch-yx
Created September 4, 2020 16:49
Show Gist options
  • Save ch-yx/f0ccdde65dfbd1e28869ac71bef1f09e to your computer and use it in GitHub Desktop.
Save ch-yx/f0ccdde65dfbd1e28869ac71bef1f09e to your computer and use it in GitHub Desktop.
[] -> ()
def f():
import marshal
tuplis=[]
def ltot(inpl):
if id(inpl) in tuplis:
return b"r"+tuplis.index(id(inpl)).to_bytes(4,"little")
else:
tuplis.append(id(inpl))
ret=b"\xa9"+len(inpl).to_bytes(1,"little")
for i in inpl:
ret+=ltot(i)
return ret
def conv(inpl):
tuplis.clear()
return marshal.loads(ltot(inpl))
return conv
conv=f()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment