<p>Is there any lib that convert very long numbers to string just copying the data?</p>

<p>These one-liners are too slow:</p>

<pre><code>def xlong(s):
    return sum([ord(c) &lt;&lt; e*8 for e,c in enumerate(s)])

def xstr(x):
    return chr(x&amp;255) + xstr(x &gt;&gt; 8) if x else ''

print xlong('abcd'*1024) % 666
print xstr(13**666)
</code></pre>

You want the struct module.
```
```
packed = struct.pack('l', 123456)
assert struct.unpack('l', packed)[0] == 123456
```
```