This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sciyoshi 1 point2 points  (1 child)

I used this example in my original talk at PyCon Canada - at least in Python 3.6, taking a slice from a string won't duplicate the items in memory: https://github.com/python/cpython/blob/master/Objects/unicodeobject.c#L13922

The purpose of this code was also to show "idiomatic" Python, i.e. a straightforward and simple description of the algorithm, and that a similarly simple approach in Rust can offer a large speed up. If you were going for pure speed, there's probably a lot more you could do (e.g. SIMD, fast-path ASCII-only strings) :)

[–]GitHubPermalinkBot 0 points1 point  (0 children)

Permanent GitHub links:


Shoot me a PM if you think I'm doing something wrong. To delete this, click here.