3 ms·
Why not just? def ulong64_to_int(ulong64): return (int(ulong64['high']) << 32) + int(ulong64['low'])
by zosima 5y ago
Why not just?
def ulong64_to_int(ulong64):
return (int(ulong64['high']) << 32) + int(ulong64['low'])
- dec0dedab0de 5y agoHonestly, because I always forget that bit shifting exists in Python. I did originally have it as a lambda, but broke out the variables when I made it a normal function while explaining how it worked to someone who needed it. Though the point I was trying to make is that if you're going to be sharing data, you should serialize it in a way that works for multiple languages, probably a string in this case. Or at the very least, if you're going to provide a client library for a language, you should make that library present the data in a way that makes sense for that language.