[C++-sig] tuple, list, dict, et. al

David Abrahams david.abrahams at rcn.com
Wed Jun 26 20:44:03 CEST 2002


Oh, wait: I take it back. The problem with using PySequence_Fast() is that
it changes the type of the argument. In other words, if I wrap the
following:

    object sequence_type(sequence x)
    {
        return x.attr("__class__")
    }

and then, I write:

    >>> sequence_type(xrange(10))

I want it to say

    xrange

not

    tuple

. So, I'm back to my earlier position: we can have sequence_fast for people
who want something that converts to a tuple (or preserves a list), but I
want sequence for people who want to accept any sequence without modifying
it.

-Dave



----- Original Message -----
From: "David Abrahams" <david.abrahams at rcn.com>


>
> From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>
>
> > This implies to me that it will work for any sequence, and a quick test
> just
> > convinced me that PySequence_Fast() works with o = xrange(n), even if
> traversed
> > twice.
>
> In that case, rock me, Amadeus!
>
> Just so long as we can call it python::sequence.
>
> and-not-sequence_fast-ly y'rs,
> dave







More information about the Cplusplus-sig mailing list