kenenet 0.9.0__py3-none-any.whl → 0.9.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kenenet/__init__.py CHANGED
@@ -287,10 +287,9 @@ _block_timings = defaultdict(float)
287
287
  _current_context = None
288
288
  _line_start_time = None
289
289
  _stack = []
290
- _ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)'}
290
+ _ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)', 'currentframe'}
291
291
 
292
-
293
- def time_code(print_details=True, print_chunks=True, label=None):
292
+ def time_code(details=True, chunks=True, label=None):
294
293
  global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line
295
294
 
296
295
  # Get the frame of the caller
@@ -357,20 +356,16 @@ def time_code(print_details=True, print_chunks=True, label=None):
357
356
  sys.settrace(trace_function)
358
357
 
359
358
  else:
360
- sys.settrace(None)
361
- context = _current_context
362
- _current_context = None
363
- _line_start_time = None
364
-
365
- if not _timings[context]:
366
- quick_print(f"No times recorded: {context}")
367
- return
368
-
369
- # Calculate total time regardless of printing options
370
- total_time = sum(elapsed for _, _, elapsed in _timings[context])
371
-
372
- # Print detailed line-by-line timings if requested
373
- if print_details:
359
+ if details:
360
+ sys.settrace(None)
361
+ context = _current_context
362
+ _current_context = None
363
+ _line_start_time = None
364
+
365
+ if not _timings[context]:
366
+ quick_print(f"No times recorded: {context}")
367
+ return
368
+
374
369
  sorted_timings = sorted(_timings[context], key=lambda x: x[2], reverse=True)
375
370
 
376
371
  quick_print(f"\nTime spent on each line: {context}")
@@ -383,13 +378,10 @@ def time_code(print_details=True, print_chunks=True, label=None):
383
378
  quick_print(f"{lineno:6d} | {elapsed:12.6f} | {line_content}")
384
379
 
385
380
  quick_print("-" * 80)
381
+ total_time = sum(elapsed for _, _, elapsed in _timings[context])
386
382
  quick_print(f"Total execution time: {total_time:.6f}")
387
- else:
388
- # Just print the total time if detailed printing is disabled
389
- quick_print(f"\nTotal execution time for {context}: {total_time:.6f}")
390
383
 
391
- # Print chunk summaries if requested
392
- if print_chunks and _block_timings:
384
+ if _block_timings and chunks:
393
385
  quick_print("\nTime spent on chunks of code:")
394
386
  quick_print("-" * 80)
395
387
  quick_print(f"{'Chunks':^40} | {'Time':>12} | {'% of Time Spent':>10}")
@@ -399,8 +391,9 @@ def time_code(print_details=True, print_chunks=True, label=None):
399
391
  sorted_blocks = sorted(_block_timings.items(), key=lambda x: x[1], reverse=True)
400
392
 
401
393
  for block, elapsed in sorted_blocks:
402
- percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
403
- quick_print(f"{block[:40]:40} | {elapsed:12.6f} | {percentage:10.2f}%")
394
+ if block not in _ignore_line:
395
+ percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
396
+ quick_print(f"{block[:40]:40} | {elapsed:12.6f} | {percentage:10.2f}%")
404
397
 
405
398
  quick_print("-" * 80)
406
399
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kenenet
3
- Version: 0.9.0
3
+ Version: 0.9.2
4
4
  Summary: dude what the fuck even is this package
5
5
  Home-page: https://www.youtube.com/@KiddyKene
6
6
  Author: kiddykene
@@ -0,0 +1,5 @@
1
+ kenenet/__init__.py,sha256=OSA1tIx7og8oxbvVqp15kgqrda-yNy7qPb4ry8K7998,16571
2
+ kenenet-0.9.2.dist-info/METADATA,sha256=grsmoIIL7TyubyTHBQ_QG7HxMfIJPj0u5MmobDZdk1I,633
3
+ kenenet-0.9.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
+ kenenet-0.9.2.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
+ kenenet-0.9.2.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- kenenet/__init__.py,sha256=Yaq9XqVDXyqqOzPjaEw9DVGTc5aJXOhatRThGrGB7b8,16838
2
- kenenet-0.9.0.dist-info/METADATA,sha256=73MKfyK4U4u7HCd76ZUHzkjXvt2YHxUKRM4BdJ43hbI,633
3
- kenenet-0.9.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
- kenenet-0.9.0.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
- kenenet-0.9.0.dist-info/RECORD,,