kenenet 0.9.8__py3-none-any.whl → 1.0.1__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
@@ -281,16 +281,25 @@ def time_func(func, loop=10000, *args, **kwargs):
281
281
  return elapsed
282
282
 
283
283
 
284
-
285
284
  _timings = defaultdict(list)
286
285
  _block_timings = defaultdict(float)
287
286
  _current_context = None
288
287
  _line_start_time = None
289
288
  _stack = []
290
- _ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)', 'currentframe'}
289
+ _ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename',
290
+ 'if _current_context is None:', 'sys.settrace(None)', 'Function: currentframe'}
291
+ _seen_lines = set() # Track lines we've already processed
292
+ _current_function = None
293
+ _function_lines = defaultdict(set) # Track which lines belong to which function
294
+
295
+
296
+ def quick_print(message):
297
+ """Helper function for printing with consistent formatting"""
298
+ print(message)
299
+
291
300
 
292
301
  def time_code(label=None):
293
- global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line
302
+ global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line, _seen_lines, _current_function, _function_lines
294
303
 
295
304
  # Get the frame of the caller
296
305
  frame = inspect.currentframe().f_back
@@ -303,16 +312,19 @@ def time_code(label=None):
303
312
  _line_start_time = time.time()
304
313
  _block_timings.clear()
305
314
  _stack = []
315
+ _seen_lines.clear() # Reset seen lines
316
+ _function_lines.clear() # Reset function lines mapping
306
317
 
307
318
  # Define the trace function
308
319
  def trace_function(frame, event, arg):
309
- global _line_start_time, _stack
320
+ global _line_start_time, _stack, _seen_lines, _current_function, _function_lines
310
321
 
311
322
  # Track function calls and returns
312
323
  if event == 'call':
313
324
  func_name = frame.f_code.co_name
314
325
  if func_name != 'time_code':
315
326
  _stack.append((func_name, time.time()))
327
+ _current_function = func_name # Track current function
316
328
  return trace_function
317
329
 
318
330
  elif event == 'return':
@@ -320,12 +332,19 @@ def time_code(label=None):
320
332
  func_name, start_time = _stack.pop()
321
333
  elapsed = time.time() - start_time
322
334
  _block_timings[f"Function: {func_name}"] += elapsed
335
+
336
+ # Reset current function if we're returning from it
337
+ if _current_function == func_name and _stack:
338
+ _current_function = _stack[-1][0]
339
+ elif not _stack:
340
+ _current_function = None
323
341
  return None
324
342
 
325
343
  elif event == 'line':
326
344
  # Get current line information
327
345
  lineno = frame.f_lineno
328
346
  line_content = linecache.getline(frame.f_code.co_filename, lineno).strip()
347
+ line_id = f"{lineno}:{line_content}"
329
348
 
330
349
  # Skip empty lines or comments
331
350
  if not line_content or line_content.startswith('#'):
@@ -340,12 +359,21 @@ def time_code(label=None):
340
359
  current_time = time.time()
341
360
  if _line_start_time is not None:
342
361
  elapsed = current_time - _line_start_time
343
- _timings[_current_context].append((lineno, line_content, elapsed))
344
362
 
345
- # Track loop timings
363
+ # Track relationship between current function and lines
364
+ if _current_function:
365
+ _function_lines[_current_function].add(line_id)
366
+
367
+ # For timing, we always record all executions to get accurate timing
368
+ _timings[_current_context].append((lineno, line_content, elapsed, line_id in _seen_lines))
369
+
370
+ # For loop timings, first check if it's a loop
346
371
  if re.match(r'\s*(for|while)\s+', line_content):
347
372
  loop_id = f"Loop at line {lineno}: {line_content[:40]}{'...' if len(line_content) > 40 else ''}"
348
373
  _block_timings[loop_id] += elapsed
374
+
375
+ # Mark this line as seen
376
+ _seen_lines.add(line_id)
349
377
 
350
378
  # Set new start time for next line
351
379
  _line_start_time = current_time
@@ -365,7 +393,27 @@ def time_code(label=None):
365
393
  quick_print(f"No times recorded: {context}")
366
394
  return
367
395
 
368
- sorted_timings = sorted(_timings[context], key=lambda x: x[2], reverse=True)
396
+ # Process timings to aggregate by line but only show first occurrence
397
+ aggregated_timings = defaultdict(float)
398
+ first_occurrences = {}
399
+
400
+ for lineno, line_content, elapsed, is_repeat in _timings[context]:
401
+ line_id = f"{lineno}:{line_content}"
402
+ aggregated_timings[line_id] += elapsed
403
+
404
+ # Store the first occurrence information
405
+ if line_id not in first_occurrences:
406
+ first_occurrences[line_id] = (lineno, line_content, elapsed)
407
+
408
+ # Create sorted list of first occurrences with total time
409
+ display_timings = [
410
+ (lineno, line_content, aggregated_timings[f"{lineno}:{line_content}"])
411
+ for lineno, line_content, _ in first_occurrences.values()
412
+ if line_content not in _ignore_line
413
+ ]
414
+
415
+ # Sort by elapsed time (descending)
416
+ sorted_timings = sorted(display_timings, key=lambda x: x[2], reverse=True)
369
417
 
370
418
  quick_print(f"\nTime spent on each line: {context}")
371
419
  quick_print("-" * 80)
@@ -373,11 +421,10 @@ def time_code(label=None):
373
421
  quick_print("-" * 80)
374
422
 
375
423
  for lineno, line_content, elapsed in sorted_timings:
376
- if line_content not in _ignore_line:
377
- quick_print(f"{lineno:6d} | {elapsed:12.6f} | {line_content}")
424
+ quick_print(f"{lineno:6d} | {elapsed:12.6f} | {line_content}")
378
425
 
379
426
  quick_print("-" * 80)
380
- total_time = sum(elapsed for _, _, elapsed in _timings[context])
427
+ total_time = sum(elapsed for _, _, elapsed in sorted_timings)
381
428
  quick_print(f"Total execution time: {total_time:.6f}")
382
429
 
383
430
  if _block_timings:
@@ -390,7 +437,7 @@ def time_code(label=None):
390
437
  sorted_blocks = sorted(_block_timings.items(), key=lambda x: x[1], reverse=True)
391
438
 
392
439
  for block, elapsed in sorted_blocks:
393
- if block not in _ignore_line:
440
+ if not any(ignore in block for ignore in _ignore_line):
394
441
  percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
395
442
  quick_print(f"{block[:40]:40} | {elapsed:12.6f} | {percentage:10.2f}%")
396
443
 
@@ -399,6 +446,8 @@ def time_code(label=None):
399
446
  # Clear the timing data for this context
400
447
  del _timings[context]
401
448
  _block_timings.clear()
449
+ _seen_lines.clear()
450
+ _function_lines.clear()
402
451
 
403
452
  class k:
404
453
  pass
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.1
2
+ Name: kenenet
3
+ Version: 1.0.1
4
+ Summary: dude what the fuck even is this package
5
+ Home-page: https://www.youtube.com/@KiddyKene
6
+ Author: kiddykene
7
+ Author-email: kittykingbusiness@gmail.com
8
+ Project-URL: Bug Tracker, https://github.com/kiddykene/KeneNet/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: Microsoft :: Windows
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: zhmiscellany
15
+ Requires-Dist: mss
16
+ Requires-Dist: pillow
17
+ Requires-Dist: pydub
18
+ Requires-Dist: pyperclip
19
+
20
+ sucky
21
+
22
+ shitty package that i use for making coding a quicker (and hopefully less aids) process
23
+
24
+ get_pos takes the cursor position and prints the rgb when f10 is pressed
25
+
26
+ timer is a timer kjhlfdshkijlsdfhkj;sdfjkhn
27
+
28
+ debug goes at the start and end of code and prints every variable change that happened
29
+
30
+ pp is a push pull to github, quick and easy for you lazy bastard
31
+
32
+ save_img takes an array, and a name for it and saves it to a file, which automatically cleans itself
33
+
34
+ holy fuck it's nearly 3am
35
+
36
+ load_audio takes the path to an mp3 and turns it into a class, then using multiprocessing multiple versions of that audio can be played simultaneously. This comes with a default random pitch shift of (0.9-1.1) so audio sounds sexy
37
+
38
+ time_func takes a function, the amount of times you want to loop it, and its arguments, and times the amount of time it took to execute that function
39
+
40
+ time_code goes at the start and end of the code you want to time, it then prints how long each line of code and/or block (functions and loops) took to run
41
+
42
+
43
+
44
+
45
+
@@ -0,0 +1,5 @@
1
+ kenenet/__init__.py,sha256=hu5QwzP7GM17Ob7SVo6R1aTMa8ENEPLtS2V6fD0k7cg,18825
2
+ kenenet-1.0.1.dist-info/METADATA,sha256=LmrZvLHm-Bw9XTZuNHItaA6jt6jx43y5NuA5xqNlzCM,1693
3
+ kenenet-1.0.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
+ kenenet-1.0.1.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
+ kenenet-1.0.1.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: kenenet
3
- Version: 0.9.8
4
- Summary: dude what the fuck even is this package
5
- Home-page: https://www.youtube.com/@KiddyKene
6
- Author: kiddykene
7
- Author-email: kittykingbusiness@gmail.com
8
- Project-URL: Bug Tracker, https://github.com/kiddykene/KeneNet/issues
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: Microsoft :: Windows
12
- Requires-Python: >=3.6
13
- Description-Content-Type: text/markdown
14
- Requires-Dist: zhmiscellany
15
- Requires-Dist: mss
16
- Requires-Dist: pillow
17
- Requires-Dist: pydub
18
- Requires-Dist: pyperclip
19
-
20
- sucky
@@ -1,5 +0,0 @@
1
- kenenet/__init__.py,sha256=N3-C4X0pHXQJYR_CdbGYpx9Okgd0n-wG4uvp9JGag38,16420
2
- kenenet-0.9.8.dist-info/METADATA,sha256=jmDhhRmAEnOONwHDPqo9QEpLUG-7VKOQO1kMN__785M,633
3
- kenenet-0.9.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
- kenenet-0.9.8.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
- kenenet-0.9.8.dist-info/RECORD,,