kenenet 1.0.5__py3-none-any.whl → 1.0.6__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
@@ -292,7 +292,25 @@ _current_function = None
292
292
  _function_lines = defaultdict(set) # Track which lines belong to which function
293
293
  _site_packages_dirs = [] # List to store site-packages directories
294
294
 
295
+ # Patterns for generated code constructs to ignore
296
+ _ignore_function_patterns = {
297
+ '<dictcomp>',
298
+ '<lambda>',
299
+ '<setcomp>',
300
+ '<listcomp>',
301
+ '<genexpr>',
302
+ '<comprehension>',
303
+ '<module>'
304
+ }
305
+
295
306
  # Initialize site-packages directories
307
+ import sys
308
+ import os
309
+ import inspect
310
+ import time
311
+ import re
312
+ import linecache
313
+ from collections import defaultdict
296
314
 
297
315
  # Get site-packages directories from sys.path
298
316
  for path in sys.path:
@@ -319,6 +337,10 @@ def _is_package_code(filename):
319
337
 
320
338
  return False
321
339
 
340
+ def _is_generated_construct(func_name):
341
+ """Check if the function name is a generated construct like <dictcomp>, <lambda>, etc."""
342
+ return any(pattern in func_name for pattern in _ignore_function_patterns)
343
+
322
344
 
323
345
  def time_code(label=None):
324
346
  global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line, _seen_lines, _current_function, _function_lines
@@ -348,6 +370,11 @@ def time_code(label=None):
348
370
  # Track function calls and returns
349
371
  if event == 'call':
350
372
  func_name = frame.f_code.co_name
373
+
374
+ # Skip recording generated constructs
375
+ if _is_generated_construct(func_name):
376
+ return trace_function
377
+
351
378
  if func_name != 'time_code':
352
379
  _stack.append((func_name, time.time()))
353
380
  _current_function = func_name # Track current function
@@ -356,8 +383,11 @@ def time_code(label=None):
356
383
  elif event == 'return':
357
384
  if _stack:
358
385
  func_name, start_time = _stack.pop()
359
- elapsed = time.time() - start_time
360
- _block_timings[f"Function: {func_name}"] += elapsed
386
+
387
+ # Skip recording generated constructs
388
+ if not _is_generated_construct(func_name):
389
+ elapsed = time.time() - start_time
390
+ _block_timings[f"Function: {func_name}"] += elapsed
361
391
 
362
392
  # Reset current function if we're returning from it
363
393
  if _current_function == func_name and _stack:
@@ -381,6 +411,10 @@ def time_code(label=None):
381
411
  # This might be the ending call, let's continue execution
382
412
  return trace_function
383
413
 
414
+ # Skip recording if we're in a generated construct
415
+ if _current_function and _is_generated_construct(_current_function):
416
+ return trace_function
417
+
384
418
  # Record elapsed time since last line
385
419
  current_time = time.time()
386
420
  if _line_start_time is not None:
@@ -463,7 +497,9 @@ def time_code(label=None):
463
497
  sorted_blocks = sorted(_block_timings.items(), key=lambda x: x[1], reverse=True)
464
498
 
465
499
  for block, elapsed in sorted_blocks:
466
- if not any(ignore in block for ignore in _ignore_line):
500
+ # Filter out generated constructs and ignored lines
501
+ if (not any(ignore in block for ignore in _ignore_line) and
502
+ not any(pattern in block for pattern in _ignore_function_patterns)):
467
503
  percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
468
504
  quick_print(f"{block[:40]:40} | {elapsed:12.6f} | {percentage:10.2f}%")
469
505
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kenenet
3
- Version: 1.0.5
3
+ Version: 1.0.6
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=9-wRVH9wkUX6ivZSU5qp1bmW3zLQ5uzOOs9Fz-wiwhM,21796
2
+ kenenet-1.0.6.dist-info/METADATA,sha256=eAlg0SPPCd5loqaHciquo2WsrHeoJSwlOVOFO0M7e0Y,1693
3
+ kenenet-1.0.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
+ kenenet-1.0.6.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
+ kenenet-1.0.6.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- kenenet/__init__.py,sha256=p2bl59OmW7OI5L0HPAcDYqDqigIik0Js4djFqRIDaVA,20517
2
- kenenet-1.0.5.dist-info/METADATA,sha256=A3rWN_i3R21vkdykLlo_8VryFM497ZF16eS29uiARnQ,1693
3
- kenenet-1.0.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
- kenenet-1.0.5.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
- kenenet-1.0.5.dist-info/RECORD,,