converting to string
Gandalf
gandalf at geochemsource.com
Wed Aug 4 03:27:50 EDT 2004
Ajay Brar wrote:
> hi!
>
> how do i go about converting a Python object or tuple to a string.
> i am currently doing
> import cPickle as pickle
> str = pickle.dumps(obj)
>
> is that efficient? is that the best way to do it?
Yes. You did not tell what the items in the tuple can be so I guess this
is the most efficient.
For special cases you can find a more efficient solution.For example,
for tuples of integers,
you can write a C extension that allocates a big string and copies every
int object into 4 bytes
in the string. That would be more efficient.
Regards,
Laci 2.0
More information about the Python-list
mailing list