Re: Slices when extending python with C++

rozelak at volny.cz rozelak at volny.cz
Wed Dec 28 18:32:27 EST 2011


Great, it's working! Thank you very much, Robert!
Dan T.

----- PŮVODNÍ ZPRÁVA -----
Od: "Robert Kern" <robert.kern at gmail.com>
Komu: python-list at python.org
Předmět: Re: Slices when extending python with C++
Datum: 28.12.2011 - 14:18:36

> On 12/28/11 1:01 PM, rozelak at volny.cz wrote:
> > Dear Robert,
> >
> > thank you very much for your answer. I
> > understand what you mean and
> > > I have looked at slice object and C-api methods
> > it provides. It
> > > should be easy to implement it.
> >
> > The only question is how exactly yo implement
> > the general getter,
> > > since sq_item you mention (assume you mean
> > PySequenceMethods.sq_item) has the following
> > signature:
> > >
> > PyObject * (* ssizeargfunc)(PyObject *,
> > Py_ssize_t)
> > >
> > accepting Py_ssize_t as the index, not a
> > PyObject * which would hold
> > > the slice.
> >
> > So, how exactly to implement the getter? As a
> > general method named
> > > __getitem__ registered in PyMethodDef? Or in
> > another way?
> > 
> Sorry, PyMappingMethods.mp_subscript is the
> general function that you need to 
> implement.
> 
> -- 
> Robert Kern
> 
> "I have come to believe that the whole world is an
> enigma, a harmless enigma
> that is made terrible by our own mad attempt to
> interpret it as though it had
> an underlying truth."
> -- Umberto Eco
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
Tradiční i moderní adventní a novoroční zvyky, sváteční jídlo a
pití, výzdoba a dárky... - čtěte vánoční a silvestrovský speciál
portálu VOLNÝ.cz na http://web.volny.cz/data/click.php?id=1301




More information about the Python-list mailing list