Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] PEP for new dictionary implementation

Jim Jewettjimjjewett at gmail.com
Fri Feb 17 18:42:40 CET 2012


On Fri, Feb 17, 2012 at 1:50 AM, "Martin v. Löwis" <martin at v.loewis.de> wrote:>>> Good idea. However, how do you track per-dict how large the>>> table is?[Or, rather, what is the highest index needed to store any valuesthat are actually set for this instance.]> To determine whether it needs to grow the array, it needs to find out> how large the array is, no? So: how do you do that?Ah, now I understand; you do need a single ssize_t either on the dictor at the head of the values array to indicate how many slots it hasactually allocated.  It *may* also be worthwhile to add a secondssize_t to indicate how many are currently in use, for faster resultsin case of len.  But the dict is guaranteed to have at least one freeslot, so that extra index will never make the allocation larger thanthe current code.-jJ


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp