From 429c6d38614072d574e22d7aabbe08ff566ab60c Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Tue, 8 Feb 2022 20:05:39 +0000 Subject: [PATCH] optimization for measure --- CHANGELOG.md | 8 ++++++-- pyproject.toml | 2 +- rich/measure.py | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a53bb62..9c1416a5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [11.2.0] - 2022-02-08 ### Added @@ -13,11 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `rich.diagnose.report` to expose environment debugging logic as function https://github.com/Textualize/rich/pull/1917 - Added classmethod `Progress.get_default_columns()` to get the default list of progress bar columns https://github.com/Textualize/rich/pull/1894 +### Fixed + +- Fixed performance issue in measuring text + ## [11.1.0] - 2022-01-28 ### Added - - Workaround for edge case of object from Faiss with no `__class__` https://github.com/Textualize/rich/issues/1838 - Add Traditional Chinese readme - Add `Syntax.guess_lexer`, add support for more lexers (e.g. Django templates etc.) https://github.com/Textualize/rich/pull/1869 @@ -1627,6 +1630,7 @@ Major version bump for a breaking change to `Text.stylize signature`, which corr - First official release, API still to be stabilized +[11.2.0]: https://github.com/willmcgugan/rich/compare/v11.1.0...v11.2.0 [11.1.0]: https://github.com/willmcgugan/rich/compare/v11.0.0...v11.1.0 [11.0.0]: https://github.com/willmcgugan/rich/compare/v10.16.1...v11.0.0 [10.16.1]: https://github.com/willmcgugan/rich/compare/v10.16.0...v10.16.1 diff --git a/pyproject.toml b/pyproject.toml index e8ea9bf99..4b221c35b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "rich" homepage = "https://github.com/willmcgugan/rich" documentation = "https://rich.readthedocs.io/en/latest/" -version = "11.1.0" +version = "11.2.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" authors = ["Will McGugan "] license = "MIT" diff --git a/rich/measure.py b/rich/measure.py index aea238df9..e12787c8b 100644 --- a/rich/measure.py +++ b/rich/measure.py @@ -1,5 +1,5 @@ from operator import itemgetter -from typing import Callable, Iterable, NamedTuple, Optional, TYPE_CHECKING +from typing import TYPE_CHECKING, Callable, Iterable, NamedTuple, Optional from . import errors from .protocol import is_renderable, rich_cast @@ -96,7 +96,9 @@ def get( if _max_width < 1: return Measurement(0, 0) if isinstance(renderable, str): - renderable = console.render_str(renderable, markup=options.markup) + renderable = console.render_str( + renderable, markup=options.markup, highlight=False + ) renderable = rich_cast(renderable) if is_renderable(renderable): get_console_width: Optional[