On Tue, Dec 2, 2008 at 1:22 AM, Alek Storm <[EMAIL PROTECTED]> wrote:

> This patch (attached, works with r81) adds slicing support for repeated
> fields in Python.  It implements retrieval, setting, and deletion for both
> scalar and composite repeated fields, and adds several unit tests for each
> method.
>
> There was already a remove() method for repeated scalars, but not for
> composites.  I added one without any difficulty.  Did I miss something?


How useful is a remove method on a repeated composite field? None has asked
about such. Do you have any use cases which require it? What are they?

If you want to remove a value from a repeated composite field, you basically
have to create the same composite value and pass it to .remove(). When can
this be useful?

I think removal of composite values doesn't make much sense. Maybe even
slicing ( __getslice__ could be usefull, but __setslice__ very unlikely).

In fact, this whole patch was pretty easy.  There must be some reason it
> hasn't been done before.


The problem is not in adding slicing support. The problem is that if there
is a Python/C API at some point, it will be very hard to translate the
slicing support to the C++ API. However repeated scalar slicing is
translatable (using RepeatedField's Set/RemoveLast/Add methods) but I don't
think slicing of repeated composite fields is possible with the C++ API.

I think we should only keep the repeated scalar slicing and maybe only
__getslice__ and __delslice__ for repeated composites.


>
> The __eq__() method for repeated composites disallows comparing to any
> other sequence type, including ordinary lists.  Why can't we do this?
>

>
> Adding more methods to the _RepeatedScalarFieldContainer and
> _RepeatedCompositeFieldContainer classes makes it even more painfully
> obvious that they need to be merged.  I'm sure we can make it polymorphic,
> and that'll probably be my next patch.
>
> The docs aren't on the wiki, so I can't add anything about this.  Are there
> plans to move it to the wiki, by any chance?
>
> Thanks,
> Alek Storm
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to