[Python-Dev] Adding insint() function

Barry A. Warsaw bwarsaw@beopen.com
Fri, 18 Aug 2000 11:27:41 -0400 (EDT)


>>>>> "AK" == Andrew Kuchling <akuchlin@mems-exchange.org> writes:

    AK> Four modules define insint() functions to insert an integer
    AK> into a dictionary in order to initialize constants in their
    AK> module dictionaries:

    | kronos Modules>grep -l insint *.c
    | pcremodule.c
    | shamodule.c
    | socketmodule.c
    | zlibmodule.c
    | kronos Modules>          

    AK> (Hm... I was involved with 3 of them...)  Other modules don't
    AK> use a helper function, but just do PyDict_SetItemString(d,
    AK> "foo", PyInt_FromLong(...)) directly.

    AK> This duplication bugs me.  Shall I submit a patch to add an
    AK> API convenience function to do this, and change the modules to
    AK> use it?  Suggested prototype and name: PyDict_InsertInteger(
    AK> dict *, string, long)

+0, but it should probably be called PyDict_SetItemSomething().  It
seems more related to the other PyDict_SetItem*() functions, even
though in those cases the `*' refers to the type of the key, not the
value.

-Barry