[Python-3000] Making more effective use of slice objects in Py3k

Jack Diederich jack at psynchronous.com
Thu Aug 31 06:43:54 CEST 2006

On Wed, Aug 30, 2006 at 08:56:03PM -0700, Bob Ippolito wrote:
> On 8/30/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> > Fredrik Lundh wrote:
> >
> > > not necessarily, but there are lots of issues involved when doing
> > > high-performance XML stuff, and I'm not sure views would help quite as
> > > much as one might think.
> > >
> > > (writing and tuning cET was a great way to learn that not everything
> > > that you think you know about C performance applies to C code running
> > > inside the Python interpreter...)
> >
> > and also based on the cET (and NFS) experiences, it wouldn't surprise me
> > if a naive 32-bit text string implementation will, on average, slow things down
> > *more* than any string view implementation can speed things up again...
> >
> > (in other words, I'm convinced that we need a polymorphic string type.  I'm not
> > so sure we need views, but if we have the former, we can use that mechanism to
> > support the latter)
> +1 for polymorphic strings.
> This would give us the best of both worlds: compact representations
> for ASCII and Latin-1, full 32-bit text when needed, and the
> possibility to implement further optimizations when necessary. It
> could add a bit of complexity and/or a massive speed penalty
> (depending on how naive the implementation is) around character
> operations though.
> For implementation ideas, Apple's CoreFoundation has a mature
> implementation of polymorphic strings in C (which is the basis for
> their NSString type in Objective-C), and there's a cross-platform
> subset of it available as CF-Lite:
> http://developer.apple.com/opensource/cflite.html

Having watched Fredrik casually double the speed of many str and unicode 
operations in a week I'm easily +1 on whatever he says.  Bob's support 
makes that a +2, he struck me as quite sane too.

That said can you guys expand on what polymorphic[1] means here in particular?
Python wise I can only think of the str/unicode/buffer split.  If the 
fraternity of strings doesn't include views (which I haven't needed either)
what are you considering for the other kinds?


[1] My ten pound Webster's says
    "An organism having more that one adult form, as the different castes 
    in social ants" which is close enough to what I think the comp sci
    definition is.

More information about the Python-3000 mailing list