[Python-Dev] Broader iterable support for xmlrpclib

Guido van Rossum guido at python.org
Wed Dec 7 16:39:39 CET 2005


On 12/7/05, skip at pobox.com <skip at pobox.com> wrote:
>
>     >> I then proposed the even wackier idea to simply allow all currently
>     >> unsupported iterables (sets and arrays seem the most obvious
>     >> candidates to me) to be marshalled as lists
>
>     Raymond> Doesn't the appropriate conversion depend on the contract
>     Raymond> between the sender and receiver (i.e. an array of type 'c' may
>     Raymond> either be converted as list(arr) or arr.tostring() depending on
>     Raymond> the app)?  Is the goal to save writing explicit conversions by
>     Raymond> presuming that most iterables aspire to be lists for transport
>     Raymond> purposes?
>
> Sure, I suspect it depends on the contract.  The contract my patch enforces
> is whether or not list(obj) succeeds.  If that fails, a TypeError is raised
> as before.  If it succeeds incorrectly, I suspect the programmer will figure
> that out soon enough and make the appropriate adjustment.  In the common
> case though, I suspect it will work though.  As indicated in the patch
> submission, the goals are to:
>
>   * extend the set of sequences that can be marshalled transparently
>
>   * keep the caller from caring as much about the limitations of the XML-RPC
>     datatypes

I think this is a bad idea. XML-RPC is severely limited in what it can
handle; it is NOT a general marshalling protocol for Python data
types. It's better to be aware of this than to try and ignore it.
Having to write list(x) means that you are aware that you're consuming
any iterators. It also means that mistakes (e.g. passing in a file)
are caught earlier.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list