[Python-Dev] Counting collisions for the win

Steven D'Aprano steve at pearwood.info
Sat Jan 21 01:53:31 CET 2012


Guido van Rossum wrote:
> On Fri, Jan 20, 2012 at 11:51 AM, Donald Stufft <donald.stufft at gmail.com>wrote:
> 
>>  On Friday, January 20, 2012 at 2:36 PM, Tres Seaver wrote:
>>
>> On 01/20/2012 02:04 PM, Donald Stufft wrote:
>>
>> Even if a MemoryException is raised I believe that is still a
>> fundamental change in the documented contract of dictionary API.
>>
>> How so? Dictionary inserts can *already* raise that error.
>>
>> Because it's raising it for a fundamentally different thing. "You have
>> plenty of memory, but we decided to add an arbitrary limit that has nothing
>> to do with memory and pretend you are out of memory anyways".
>>
> 
> Actually due to fragmentation that can already happen.

Whether you have run out of total memory, or a single contiguous block, it is 
still a memory error.

An arbitrary limit on collisions is not a memory error. If we were designing 
this API from scratch, would anyone propose using MemoryError for "you have 
reached a limit on collisions"? It has nothing to do with memory. Using 
MemoryError for something which isn't a memory error is ugly.

How about RuntimeError?



-- 
Steven



More information about the Python-Dev mailing list