[Python-checkins] r73850 - in python/branches/py3k: Lib/test/test_array.py Modules/arraymodule.c

Nick Coghlan ncoghlan at gmail.com
Sun Jul 5 22:37:46 CEST 2009


Alexandre Vassalotti wrote:
> On Sun, Jul 5, 2009 at 4:36 AM, Antoine Pitrou<solipsis at pitrou.net> wrote:
>> <alexandre.vassalotti> writes:
>>> +    def test_memoryview_no_resize(self):
>>> +        # Test for issue 4509.
>> Perhaps you should have expanded the existing test_buffer() method instead?
>>
> 
> Ah, thanks! And moving the tests to test_buffer exposed yet another bug!
> 
> Now, I wonder why array defines item getters/setters both for the
> sequence protocol and mapping protocol...

While I can't say for sure, my guess is that it would be due to the fact
that most of the builtin and standard library types were written before
extended slicing was added. When support for that was added by
implementing the mapping protocol, support for the old sequence methods
was retained.

Keeping the implementation of the sequence protocol also triggers things
like support for the default sequence iterator in iter() and
operator.isSequence() returning True.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-checkins mailing list