[Python-Dev] frozenset C API?
Bill Janssen
janssen at parc.com
Tue Sep 4 21:21:37 CEST 2007
I'm working on issue 1583946. Nagle pointed out that each DN (the
"subject" and "issuer" fields in a certificate) may have multiple
values for the same attribute name, and I haven't been able to rule
this out yet. X.509 DNs are sets of X.500 attributes, and X.500
attributes may be either single-valued or multiple-valued. I haven't
found anything in the X.509 standard that prohibits multiple-valued
attributes (yet -- I'm still looking), so I'm working on an
alternative to using dicts to represent the set of attributes in the
certificate that's returned from ssl.sslsocket.getpeercert().
"frozenset" seems the most appropriate -- it's a non-ordered immutable
set of attributes. Could use a tuple, but (1) that implies order,
and (2) using set operations on the attribute set would be handy to
test for various things, particularly "issubset" and "issuperset".
I think frozenset is quite analogous to tuple at this level, and I
suggest that a similar set of C construction functions would be a good
thing.
Bill
> I guess nobody has tried to create frozenset instances from C code
> before. Almost everyone uses set anyway. What are you trying to do?
>
> On 9/4/07, Bill Janssen <janssen at parc.com> wrote:
> > I'm looking at building a "frozenset" instance as a return value from
> > a C function, and the C API seems ridiculously clumsy. Maybe I'm
> > misunderstanding it. Apparently, I need to create a list object, then
> > pass that to PyFrozenSet_New(), then decref the list object.
> >
> > Is that correct?
> >
> > What I'd like is something more like
> >
> > PyFrozenSet_NEW(int) => PySetObject *
> > PyFrozenSet_SET_ITEM(s, i, v)
> >
> > Any idea why these aren't part of the API?
> >
> > Bill
> > _______________________________________________
> > Python-Dev mailing list
> > Python-Dev at python.org
> > http://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
> >
>
>
> --
> --Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list