From 2019c04e429aecabbadf9fc912a6dbccda5db34c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugenio=20Parodi=20=F0=9F=8C=B6=EF=B8=8F?= Date: Sat, 28 Dec 2024 23:08:45 +0000 Subject: [PATCH] retuned the string rasterizer --- TermTk/TTkCore/string.py | 12 ++++-------- tests/timeit/02.array.08.List.vs.Tuple.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/TermTk/TTkCore/string.py b/TermTk/TTkCore/string.py index c431262f..983a1775 100644 --- a/TermTk/TTkCore/string.py +++ b/TermTk/TTkCore/string.py @@ -678,8 +678,6 @@ class TTkString(): def _getDataW_pts(self): retTxt = [] retCol = [] - retTxt_append = retTxt.append - retCol_append = retCol.append for ch,color in zip(self._text,self._colors): if unicodedata.east_asian_width(ch) == 'W': retTxt += (ch,'') @@ -694,22 +692,20 @@ class TTkString(): # retTxt = [f"{ch}"] # retCol = [TTkColor.RST] else: - retTxt_append(ch) - retCol_append(color) + retTxt.append(ch) + retCol.append(color) return (retTxt, retCol) def _getDataW_tty(self): retTxt = [] retCol = [] - retTxt_append = retTxt.append - retCol_append = retCol.append for ch,color in zip(self._text,self._colors): if unicodedata.east_asian_width(ch) == 'W': retTxt += ('■','■') retCol += (color,color) elif unicodedata.category(ch) not in ('Me','Mn'): - retTxt_append(ch) - retCol_append(color) + retTxt.append(ch) + retCol.append(color) return (retTxt, retCol) if os.environ.get("TERMTK_GPM",False): diff --git a/tests/timeit/02.array.08.List.vs.Tuple.py b/tests/timeit/02.array.08.List.vs.Tuple.py index d87d4815..5e194f9d 100755 --- a/tests/timeit/02.array.08.List.vs.Tuple.py +++ b/tests/timeit/02.array.08.List.vs.Tuple.py @@ -42,7 +42,7 @@ def test_ti_02(): a += [i,i,i,i,i,i] return len(a) -def test_ti_03(): +def test_ti_03_01(): a = [] a_a = a.append for i in range(100): @@ -54,6 +54,17 @@ def test_ti_03(): a_a(i) return len(a) +def test_ti_03_02(): + a = [] + for i in range(100): + a.append(i) + a.append(i) + a.append(i) + a.append(i) + a.append(i) + a.append(i) + return len(a) + def test_ti_04(): a = [x for i in range(100) for x in (i,i,i,i,i,i)] return len(a)