does Python support some kind of "casting"
Duncan Booth
duncan at NOSPAMrcp.co.uk
Thu Mar 14 11:48:08 EST 2002
Tino Lange <tl_news at nexgo.de> wrote in
news:a6q6hu$1c6$1 at crusher.de.colt.net:
> So the best solution is to transport an object like
> return list(newlist)
>
> But I guess this makes a temporary copy of my MaxSizedList just for the
> XML-RPC-transport, or? So it's horrible inefficient?
>
>
Yes, that will make a copy. But copying a list is a pretty efficient
operation, so no, it isn't really horribly inefficient. Have you tried it
and identified this as a bottleneck? How long are your lists anyway?
One way to do this that avoids the copying is to aggregate a list object
into your class instead of trying to subclass the list type. Then you can
simply return the internal list object if you want.
However, from your description I would be much more worried about the
throwing away elements from the front of the list every time you append to
the end of the list. I do hope you are batching these up into large chunks
to be discarded, not throwing them away one or two at a time.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list