Hi,
somehow I kept interest in this and found a better solution. Splitting
the whole text first into words is only the best way when the line width
is close to the average word length. In the more typical cases you have
multiple words per line, and then it's faster to process line by line by
look
On 12/15/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
> On 12/15/06 11:26 AM, Michael Radziej wrote:
> > when I watched the presentation of GvR's Mondrian, his statement
> > that django's word wrapper has quadratic behaviour made me take a
> > look. Here's the result ...
>
> Awesome patch, Mic
On 12/15/06 1:28 PM, John Lenton wrote:
> I don't have a 100M text to test with, but I was wondering how changing that
> to
>
> it = (m.group() for m in re.finditer(r'(\S+)', text))
>
> would compare in both speed and memory?
> (I expect it to use about half as much memory, due to not copying
On 12/15/06, Michael Radziej <[EMAIL PROTECTED]> wrote:
>
> it = iter(text.split(' '))
I don't have a 100M text to test with, but I was wondering how changing that to
it = (m.group() for m in re.finditer(r'(\S+)', text))
would compare in both speed and memory?
(I expect it to use abo
On 12/15/06 11:26 AM, Michael Radziej wrote:
> when I watched the presentation of GvR's Mondrian, his statement
> that django's word wrapper has quadratic behaviour made me take a
> look. Here's the result ...
Awesome patch, Michael. I tested your function a bit myself, made a small
tweak for
Hi,
when I watched the presentation of GvR's Mondrian, his statement
that django's word wrapper has quadratic behaviour made me take a
look. Here's the result ...
def wrap(text, width):
def _generator():
it = iter(text.split(' '))
for word in it:
yield word