RE Module Performance

Neil Hodgson nhodgson at iinet.net.au
Tue Jul 30 23:09:54 EDT 2013


MRAB:

> The disadvantage there is that when you move the cursor you must move
> characters around. For example, what if the cursor was at the start and
> you wanted to move it to the end? Also, when the gap has been filled,
> you need to make a new one.

    The normal technique is to only move the gap when text is added or 
removed, not when the cursor moves. Code that reads the contents, such 
as for display, handles the gap by checking the requested position and 
using a different offset when the position is after the gap.

    Gap buffers work well because changes are generally close to the 
previous change, so require moving only a relatively small amount of 
text. Even an occasional move of the whole contents won't cause too much 
trouble for interactivity with current processors moving multiple 
megabytes per millisecond.

    Neil



More information about the Python-list mailing list