Python speed and `pcre'

François Pinard pinard at iro.umontreal.ca
Thu Sep 2 10:23:07 EDT 1999


"Fredrik Lundh" <fredrik at pythonware.com> écrit:

> François Pinard <pinard at iro.umontreal.ca> wrote:
> > Yes, of course.  Given strings are immutable, an implementation could have:
> >
> >         ref=str
> >         str=str+str1
> >
> > and have `ref' points to a substring of `str', without copy most of
> > the time, when `str1' is small.

> what do you do when you have to reallocate str?

Then, you have copies.  The substring is still referenced.  How to
implement that?  I do not know and would have to study the matter to find
possible answers, but it really is an implementation issue, that should
not bother users.

The key point of the whole argument is that people should program in Python
in the spirit of its simplicity, while the implementor should worry about
how to make the implementation speedy.  It is not healthy that users need
to know how things are implemented, then alter their programming style.
It does not fit well in what I understand from Python, as a language.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list