[C++-sig] tuple::size()
David Abrahams
dave at boost-consulting.com
Thu Aug 29 07:58:12 CEST 2002
From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>
> If I want to know the length of a tuple, list or dict, currently I have
to
> #include a certain file with a long path.
Which file? I didn't think that was in the public library interfacee yet.
And, BTW:
x.attr("__len__")()
> On top of that, if I am not in
> namespace boost::python, I have to type "boost::python::len(o)".
Is Koenig lookup broken on your compiler?
For MSVC, those names should be imported into std::
> Points:
>
> - Having to #include <boost/python/whatever.hpp> is cumbersome and brings
more
> code into scope than I really need.
How much stuff comes into scope all depends on how much stuff is in
whatever.hpp
> - boost::python::len() is quite a bit of clutter.
So don't use qualification.
> - .size() is what one expects to have in C++.
>
> - .size() could directly look at sq_length and thus generate less code.
>
> David, would you be very upset if I added .size() to tuple.hpp, list.hpp
and
> dict.hpp?
A little. I don't think that
len(x)
is too cumbersome.
I want the interface for using those objects to look like the Python
interface. I don't think it's a good idea to use the C++ idioms. The next
thing you know, people will want mutable random-access iterators for
python::list, to make it act like std::vector... which would be fine if it
were possiblee (but it isn't).
-Dave
-----------------------------------------------------------
David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list