[IPython-dev] comm_info_[request/reply] : addition to the messaging protocol

Chris Colbert sccolbert at gmail.com
Wed Jul 1 17:01:03 EDT 2015


On Wed, Jul 1, 2015 at 4:45 PM, MinRK <benjaminrk at gmail.com> wrote:

>
>
> On Wed, Jul 1, 2015 at 1:35 PM, Chris Colbert <sccolbert at gmail.com> wrote:
>
>> I'm +1 on the idea, but -1 on the proposed format of the message. It's
>> really difficult to specify a schema for the message when the keys of the
>> message are dynamic. In this case, the key `comm_id` can be anything, which
>> makes validating the message difficult, and defining a corresponding object
>> type (other than a hash table) for the message impossible.
>>
>> If instead you list the active comms as an array of pairs, it becomes
>> very easy to both define the schema for the message, as well as handle the
>> message on the client-side. Something like:
>>
>> `{ type: 'comm_info_reply', comms: [ { id: 'foo', target:
>> 'ipython.widget' }, ... ] }`
>>
>
> On the other hand, the hash table is much better for answering the
> question 'is this id present' than a list. So to some degree, it's a
> question of which sort of action is more likely based on the reply:
>
>
IMO this concern is secondary to ensuring you receive the data you
expected. You have to iterate the whole structure at least once to validate
it anyway. During that validation, you may opt to convert it to a hash
table or whatever else you need for the task you're about to perform. But I
think it's crucial to be able to schematize the messages (both for
validation and documentation) and dynamic keys make that very difficult.

1. check if a particular entry present
> 2. iterate through all entries, and take some action (list, display,
> reconnect, etc.)
>
> Even if it remains a hash table, the values should probably be dicts, so
> that there is a place for info about each comm to grow, if we see a need
> for it.
>
> -MinRK
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150701/135d914e/attachment.html>


More information about the IPython-dev mailing list