[Python-ideas] string codes & substring equality
Steven D'Aprano
steve at pearwood.info
Fri Nov 29 10:06:44 CET 2013
On Fri, Nov 29, 2013 at 07:40:12AM +0100, spir wrote:
> Now, there is a mystery: how is the time for creating a single-char string
> object about half the time of a simple indexing (in C!)? This just cannot
> be, can it?
Of course it can be. What makes you think that creating small strings
will be expensive? There is some cost, of course, but I expect that
creating a small string will be very cheap.
Not quite as cheap as C of course, since Python does a lot more for you,
and creates rich objects rather than just copying low-level bytes, but
it won't be expensive to take a small slice of a string.
--
Steven
More information about the Python-ideas
mailing list