Browse Source

Lint: FIX: E713

pull/260/head
Eugenio Parodi 2 years ago
parent
commit
cea6509664
  1. 4
      TermTk/TTkCore/string.py
  2. 2
      TermTk/TTkCrossTools/savetools.py
  3. 4
      TermTk/TTkUiTools/uiloader.py
  4. 52
      tests/timeit/25.comparison.02.py

4
TermTk/TTkCore/string.py

@ -624,7 +624,7 @@ class TTkString():
def nextPos(self, pos):
pos += 1
for i,ch in enumerate(self._text[pos:]):
if not unicodedata.category(ch) in ('Me','Mn'):
if unicodedata.category(ch) not in ('Me','Mn'):
return pos+i
return len(self._text)
@ -634,7 +634,7 @@ class TTkString():
# TTkLog.debug(f"{str(reversed(self._text[:pos]))} {pos=}")
for i,ch in enumerate(reversed(self._text[:pos])):
# TTkLog.debug(f"{i}---> {ch} ")
if not unicodedata.category(ch) in ('Me','Mn'):
if unicodedata.category(ch) not in ('Me','Mn'):
return pos-i-1
return 0

2
TermTk/TTkCrossTools/savetools.py

@ -73,7 +73,7 @@ if importlib.util.find_spec('pyodideProxy'):
pyodideProxy.saveFile(os.path.basename(filePath), content, encoding)
def _connectDragOpen(encoding, cb):
if not encoding in ttkDragOpen:
if encoding not in ttkDragOpen:
ttkDragOpen[encoding] = pyTTkSignal(dict)
return ttkDragOpen[encoding].connect(cb)

4
TermTk/TTkUiTools/uiloader.py

@ -289,7 +289,7 @@ class TTkUiLoader():
def _getSignal(sender, name):
for cc in reversed(type(sender).__mro__):
if cc.__name__ in TTkUiProperties:
if not name in TTkUiProperties[cc.__name__]['signals']:
if name not in TTkUiProperties[cc.__name__]['signals']:
continue
signame = TTkUiProperties[cc.__name__]['signals'][name]['name']
return getattr(sender,signame)
@ -298,7 +298,7 @@ class TTkUiLoader():
def _getSlot(receiver, name):
for cc in reversed(type(receiver).__mro__):
if cc.__name__ in TTkUiProperties:
if not name in TTkUiProperties[cc.__name__]['slots']:
if name not in TTkUiProperties[cc.__name__]['slots']:
continue
slotname = TTkUiProperties[cc.__name__]['slots'][name]['name']
return getattr(receiver,slotname)

52
tests/timeit/25.comparison.02.py

@ -0,0 +1,52 @@
#!/usr/bin/env python3
# MIT License
#
# Copyright (c) 2023 Eugenio Parodi <ceccopierangiolieugenio AT googlemail DOT com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import timeit, pickle
lll = ('ab','cd')
def test1(): return 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd') , 'ab' in ('ab','cd')
def test2(): return not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd') , not 'ab' in ('ab','cd')
def test3(): return 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd') , 'ab' not in ('ab','cd')
def test4(): return 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd') , 'az' in ('ab','cd')
def test5(): return not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd') , not 'az' in ('ab','cd')
def test6(): return 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd') , 'az' not in ('ab','cd')
def test7(): return 'ab' in lll , 'ab' in lll , 'ab' in lll , 'ab' in lll , 'ab' in lll , 'ab' in lll , 'ab' in lll , 'ab' in lll , 'ab' in lll , 'ab' in lll
def test8(): return not 'ab' in lll , not 'ab' in lll , not 'ab' in lll , not 'ab' in lll , not 'ab' in lll , not 'ab' in lll , not 'ab' in lll , not 'ab' in lll , not 'ab' in lll , not 'ab' in lll
def test9(): return 'ab' not in lll , 'ab' not in lll , 'ab' not in lll , 'ab' not in lll , 'ab' not in lll , 'ab' not in lll , 'ab' not in lll , 'ab' not in lll , 'ab' not in lll , 'ab' not in lll
def test10(): return 'az' in lll , 'az' in lll , 'az' in lll , 'az' in lll , 'az' in lll , 'az' in lll , 'az' in lll , 'az' in lll , 'az' in lll , 'az' in lll
def test11(): return not 'az' in lll , not 'az' in lll , not 'az' in lll , not 'az' in lll , not 'az' in lll , not 'az' in lll , not 'az' in lll , not 'az' in lll , not 'az' in lll , not 'az' in lll
def test12(): return 'az' not in lll , 'az' not in lll , 'az' not in lll , 'az' not in lll , 'az' not in lll , 'az' not in lll , 'az' not in lll , 'az' not in lll , 'az' not in lll , 'az' not in lll
loop = 500000
a = {}
iii = 1
while (testName := f'test{iii}') and (testName in globals()):
result = timeit.timeit(f'{testName}(*a)', globals=globals(), number=loop)
# print(f"test{iii}) fps {loop / result :.3f} - s {result / loop:.10f} - {result / loop} {globals()[testName](*a)}")
print(f"test{iii:02}) | {result / loop:.10f} sec. | {loop / result : 15.3f} Fps ╞╡-> {globals()[testName](*a)}")
iii+=1
Loading…
Cancel
Save