[C++-sig] bpl_utils update

David Abrahams dave at boost-consulting.com
Thu Jul 25 19:00:58 CEST 2002


----- Original Message -----
From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>

> > Okay, sounds great. However, we also need reference documentation of
the
> > type that's already in CVS. To write that, we need to at least decide
on
> > the filenames.
>
> I'd find it most efficient if you make a unilateral (IOW dictatorial)
decision.

OK. To do that I need to get a better understanding of what you've done. I
will be asking questions.

> > > To get things off the ground, I'd suggest to limit ourselves
initially to
> > > "measurable" sequences (that's what the code is doing now; checks
> > should/could
> > > be added).
> >
> > I'm not sure that checking is possible, at least not today. And Guido
seems
> > rather hostile to the idea of making it possible, though I might be
> > misinterpreting him. See
> >
http://aspn.activestate.com/ASPN/search?query=Single-+vs.+Multi-pass+iterab
> > ility&type=Archive_python-dev
> > for details.
>
> 161 messages! Help!!!
> I cannot afford to be scientific about this.

Sorry. For a condensed version, check
http://aspn.activestate.com/ASPN/Mail/Message/1284483
http://aspn.activestate.com/ASPN/Mail/Message/1284538
http://aspn.activestate.com/ASPN/Mail/Message/1287379
http://aspn.activestate.com/ASPN/Mail/Message/1287432

> Idea for a pragmatic approach:
>
> We add static constant to the *_registration_adaptor's; e.g.
>
> BOOST_STATIC_CONSTANT(bool, check_convertibility_per_element = true);
>
> Then in convertible():
>
> if (ContainerAdaptor::check_convertibility_per_element == true) {
>   if (PyObject_Length(obj) < 0) return 0;
>   // we traverse the sequence and return 0 if any element is not
convertible
>   return obj;
> }
> if (PyObject_Length(obj) >= 0) return obj;
> PyErr_Clear();
> if (handle<>(allow_null(PyObject_GetIter(obj))).get()) return obj;
> PyErr_Clear();
> return 0;
>
> In construct() we do it the other way round:
> 1. try PyObject_GetIter() first and use PyIter_Next() on success.
> 2. if that fails fall back to PySequence_Fast()

I need to look at your stuff in more detail before I can evaluate these
ideas.

-Dave






More information about the Cplusplus-sig mailing list