I wrote: > I agree. It seems to me that it is not python-font-lock-extend-region > itself that is slow, but rather font-lock's processing of the area > extended by it. So one workaround would be to limit the number of > lines to be extended, as in the attached patch. If this limit is > exceeded, the area or the entire buffer must be font-locked manually > later. What do you think of this idea? The cause of the slowdown seems to be in python-info-docstring-p. So another option would be to improve it. Attached is a patch that determines that if point is in parens except for "(", it is not a docstring. I can't think of a case where a docstring is in parens except for "(". However, usually more tests should be done.