[Python-checkins] r46544 - in python/trunk: Include/dictobject.h Objects/dictobject.c

Jim Jewett jimjjewett at gmail.com
Tue May 30 21:46:21 CEST 2006


Why is this being done now?

I see the advantage of being able to use larger dictionaries if you do
have the RAM, and want a few huge in-memory databases instead of a
large number of small objects, *and* aren't using something else for
that database.

I also see a disadvantage in making all dictionary instances a little
bit larger.

I think even for the huge RAM case, "lots of little objects" might be
a more common case.

Even for the single-honkin-dict, would it make sense to have an extra
search finger member instead of increasing the size of every bucket?

-jJ

On 5/30/06, tim.peters <python-checkins at python.org> wrote:
> Author: tim.peters
> Date: Tue May 30 06:16:25 2006
> New Revision: 46544
>
> Modified:
>    python/trunk/Include/dictobject.h
>    python/trunk/Objects/dictobject.c
> Log:
> Convert relevant dict internals to Py_ssize_t.
>
> I don't have a box with nearly enough RAM, or an OS,
> that could get close to tickling this, though (requires
> a dict w/ at least 2**31 entries).
>
>
> Modified: python/trunk/Include/dictobject.h
> ==============================================================================
> --- python/trunk/Include/dictobject.h   (original)
> +++ python/trunk/Include/dictobject.h   Tue May 30 06:16:25 2006
> @@ -8,7 +8,7 @@
>  /* Dictionary object type -- mapping from hashable object to object */
>
>  /* The distribution includes a separate file, Objects/dictnotes.txt,
> -   describing explorations into dictionary design and optimization.
> +   describing explorations into dictionary design and optimization.
>     It covers typical dictionary use patterns, the parameters for
>     tuning dictionaries, and several ideas for possible optimizations.
>  */
> @@ -48,7 +48,11 @@
>  #define PyDict_MINSIZE 8
>
>  typedef struct {
> -       long me_hash;      /* cached hash code of me_key */
> +       /* Cached hash code of me_key.  Note that hash codes are C longs.
> +        * We have to use Py_ssize_t instead because dict_popitem() abuses
> +        * me_hash to hold a search finger.
> +        */
> +       Py_ssize_t me_hash;
>         PyObject *me_key;
>         PyObject *me_value;
>  } PyDictEntry;


More information about the Python-checkins mailing list