2025-12-01
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import timeit
|
||||
from collections import namedtuple
|
||||
|
||||
from ..maths import Vector, Point, Direction, Normal
|
||||
|
||||
NTPoint = namedtuple('Point', ['x', 'y', 'z'])
|
||||
|
||||
kwargs = {
|
||||
'number': 10000,
|
||||
'globals': globals(),
|
||||
}
|
||||
|
||||
timings = []
|
||||
timings += [timeit.timeit('[Vector((0,1,2)) for i in range(1000)]', **kwargs)]
|
||||
#timings += [timeit.timeit('[VectorOld((0,1,2)) for i in range(1000)]', **kwargs)]
|
||||
timings += [timeit.timeit('[Point((0,1,2)) for i in range(1000)]', **kwargs)]
|
||||
timings += [timeit.timeit('[Direction((0,1,2)) for i in range(1000)]', **kwargs)]
|
||||
timings += [timeit.timeit('[Normal((0,1,2)) for i in range(1000)]', **kwargs)]
|
||||
timings += [timeit.timeit('[(0,1,2) for i in range(1000)]', **kwargs)]
|
||||
timings += [timeit.timeit('[[0,1,2] for i in range(1000)]', **kwargs)]
|
||||
timings += [timeit.timeit('[NTPoint(0,1,2) for i in range(1000)]', **kwargs)]
|
||||
|
||||
|
||||
print(timings)
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import glob
|
||||
|
||||
if len(sys.argv) < 2 or sys.argv[1] != 'YES!':
|
||||
print('CAUTION: running this will alter **ALL** .py files in every subdirectory!')
|
||||
print('To ensure you are certain you want to run it, call %s again with the argument "YES!"' % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
re_function = re.compile(r'\n(?P<indent> *)(?P<pr>@profiler\.function)\n')
|
||||
re_add_note = re.compile(r'\n(?P<indent> *)(?P<pr>profiler\.add_note\(.*?\))\n')
|
||||
re_withcode = re.compile(r'\n(?P<indent> *)(?P<pr>with profiler\.code\(.*?\)( +as +.*?)?:)\n')
|
||||
re_dprint = re.compile(r'\n(?P<indent> *)(?P<dp>(Debugger\.)?dprint\(.*?\))\n')
|
||||
|
||||
ignore_pyfiles = {
|
||||
'profiler.py',
|
||||
'debug.py',
|
||||
}
|
||||
ignore_folders = {
|
||||
'__pycache__',
|
||||
}
|
||||
|
||||
def go(root):
|
||||
for fn in glob.glob('*.py'):
|
||||
if fn in ignore_pyfiles: continue
|
||||
f = open(fn, 'rt').read()
|
||||
of = str(f)
|
||||
while True:
|
||||
m = re_function.search(f)
|
||||
if not m: break
|
||||
replace = '\n%s# %s\n' % (m.group('indent'), m.group('pr'))
|
||||
f = f[:m.start()] + replace + f[m.end():]
|
||||
while True:
|
||||
m = re_add_note.search(f)
|
||||
if not m: break
|
||||
replace = '\n%s# %s\n' % (m.group('indent'), m.group('pr'))
|
||||
f = f[:m.start()] + replace + f[m.end():]
|
||||
while True:
|
||||
m = re_withcode.search(f)
|
||||
if not m: break
|
||||
replace = '\n%sif True: # %s\n' % (m.group('indent'), m.group('pr'))
|
||||
f = f[:m.start()] + replace + f[m.end():]
|
||||
while True:
|
||||
m = re_dprint.search(f)
|
||||
if not m: break
|
||||
replace = '\n%s# %s\n%spass\n' % (m.group('indent'), m.group('dp'), m.group('indent'))
|
||||
f = f[:m.start()] + replace + f[m.end():]
|
||||
if f == of: continue
|
||||
open(fn, 'wt').write(f)
|
||||
|
||||
for fn in glob.glob('*'):
|
||||
if not os.path.isdir(fn): continue
|
||||
if fn in ignore_folders: continue
|
||||
os.chdir(fn)
|
||||
go(os.path.join(root, fn))
|
||||
os.chdir('..')
|
||||
|
||||
go('.')
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import re
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
year = f'{date.today().year:04d}'
|
||||
|
||||
ignore_dirs = {'.git', 'ext'}
|
||||
update_exts = {'.py', '.glsl', '.css'}
|
||||
ignore_exts = {'.ttf', '.exr', '.blend', '.pack', '.mtl', '.json', '.m4v', '.md', '.LICENSE', '.jpg', '.html', '.blend1', '.png', '.pyc', '.yml', '.gitignore', '.lock', '.scss', '.txt', '.obj', '', '.sh'}
|
||||
unhandled_exts = set()
|
||||
unhandled_paths = []
|
||||
|
||||
|
||||
def process(p):
|
||||
global year, update_exts, unhandled_exts, unhandled_paths, ignore_exts, ignore_dirs
|
||||
if p.is_file():
|
||||
if p.stem.startswith('.'): return
|
||||
if p.suffix not in update_exts:
|
||||
if p.suffix in ignore_exts: return
|
||||
if p.suffix in unhandled_exts: return
|
||||
unhandled_exts.add(p.suffix)
|
||||
unhandled_paths.append(p)
|
||||
return
|
||||
orig = p.read_text()
|
||||
updated = re.sub(r'Copyright \(C\) (?P<year>\d+)', f'Copyright (C) {year}', orig)
|
||||
if orig == updated: return
|
||||
print(f'Updating: {p}')
|
||||
# print(updated)
|
||||
p.write_text(updated)
|
||||
elif p.is_dir():
|
||||
if p.stem in ignore_dirs: return
|
||||
for np in p.glob('*'):
|
||||
process(np)
|
||||
else:
|
||||
unhandled_paths.append(p)
|
||||
|
||||
process(Path('.'))
|
||||
print()
|
||||
print(f'Unhandled Extensions: {unhandled_exts}')
|
||||
print(f'Unhandled Paths:')
|
||||
print('\n'.join(f'- {p}' for p in unhandled_paths))
|
||||
Reference in New Issue
Block a user