kenenet 1.0.0__py3-none-any.whl → 1.0.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
@@ -281,16 +281,19 @@ 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)', 'Function: currentframe'}
289
+ _ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)', 'Function: currentframe', 'return sys._getframe(1) if hasattr(sys, "_getframe") else None'}
290
+ _seen_lines = set() # Track lines we've already processed
291
+ _current_function = None
292
+ _function_lines = defaultdict(set) # Track which lines belong to which function
293
+
291
294
 
292
295
  def time_code(label=None):
293
- global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line
296
+ global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line, _seen_lines, _current_function, _function_lines
294
297
 
295
298
  # Get the frame of the caller
296
299
  frame = inspect.currentframe().f_back
@@ -303,16 +306,19 @@ def time_code(label=None):
303
306
  _line_start_time = time.time()
304
307
  _block_timings.clear()
305
308
  _stack = []
309
+ _seen_lines.clear() # Reset seen lines
310
+ _function_lines.clear() # Reset function lines mapping
306
311
 
307
312
  # Define the trace function
308
313
  def trace_function(frame, event, arg):
309
- global _line_start_time, _stack
314
+ global _line_start_time, _stack, _seen_lines, _current_function, _function_lines
310
315
 
311
316
  # Track function calls and returns
312
317
  if event == 'call':
313
318
  func_name = frame.f_code.co_name
314
319
  if func_name != 'time_code':
315
320
  _stack.append((func_name, time.time()))
321
+ _current_function = func_name # Track current function
316
322
  return trace_function
317
323
 
318
324
  elif event == 'return':
@@ -320,12 +326,19 @@ def time_code(label=None):
320
326
  func_name, start_time = _stack.pop()
321
327
  elapsed = time.time() - start_time
322
328
  _block_timings[f"Function: {func_name}"] += elapsed
329
+
330
+ # Reset current function if we're returning from it
331
+ if _current_function == func_name and _stack:
332
+ _current_function = _stack[-1][0]
333
+ elif not _stack:
334
+ _current_function = None
323
335
  return None
324
336
 
325
337
  elif event == 'line':
326
338
  # Get current line information
327
339
  lineno = frame.f_lineno
328
340
  line_content = linecache.getline(frame.f_code.co_filename, lineno).strip()
341
+ line_id = f"{lineno}:{line_content}"
329
342
 
330
343
  # Skip empty lines or comments
331
344
  if not line_content or line_content.startswith('#'):
@@ -340,12 +353,21 @@ def time_code(label=None):
340
353
  current_time = time.time()
341
354
  if _line_start_time is not None:
342
355
  elapsed = current_time - _line_start_time
343
- _timings[_current_context].append((lineno, line_content, elapsed))
344
356
 
345
- # Track loop timings
357
+ # Track relationship between current function and lines
358
+ if _current_function:
359
+ _function_lines[_current_function].add(line_id)
360
+
361
+ # For timing, we always record all executions to get accurate timing
362
+ _timings[_current_context].append((lineno, line_content, elapsed, line_id in _seen_lines))
363
+
364
+ # For loop timings, first check if it's a loop
346
365
  if re.match(r'\s*(for|while)\s+', line_content):
347
366
  loop_id = f"Loop at line {lineno}: {line_content[:40]}{'...' if len(line_content) > 40 else ''}"
348
367
  _block_timings[loop_id] += elapsed
368
+
369
+ # Mark this line as seen
370
+ _seen_lines.add(line_id)
349
371
 
350
372
  # Set new start time for next line
351
373
  _line_start_time = current_time
@@ -365,7 +387,27 @@ def time_code(label=None):
365
387
  quick_print(f"No times recorded: {context}")
366
388
  return
367
389
 
368
- sorted_timings = sorted(_timings[context], key=lambda x: x[2], reverse=True)
390
+ # Process timings to aggregate by line but only show first occurrence
391
+ aggregated_timings = defaultdict(float)
392
+ first_occurrences = {}
393
+
394
+ for lineno, line_content, elapsed, is_repeat in _timings[context]:
395
+ line_id = f"{lineno}:{line_content}"
396
+ aggregated_timings[line_id] += elapsed
397
+
398
+ # Store the first occurrence information
399
+ if line_id not in first_occurrences:
400
+ first_occurrences[line_id] = (lineno, line_content, elapsed)
401
+
402
+ # Create sorted list of first occurrences with total time
403
+ display_timings = [
404
+ (lineno, line_content, aggregated_timings[f"{lineno}:{line_content}"])
405
+ for lineno, line_content, _ in first_occurrences.values()
406
+ if line_content not in _ignore_line
407
+ ]
408
+
409
+ # Sort by elapsed time (descending)
410
+ sorted_timings = sorted(display_timings, key=lambda x: x[2], reverse=True)
369
411
 
370
412
  quick_print(f"\nTime spent on each line: {context}")
371
413
  quick_print("-" * 80)
@@ -373,11 +415,10 @@ def time_code(label=None):
373
415
  quick_print("-" * 80)
374
416
 
375
417
  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}")
418
+ quick_print(f"{lineno:6d} | {elapsed:12.6f} | {line_content}")
378
419
 
379
420
  quick_print("-" * 80)
380
- total_time = sum(elapsed for _, _, elapsed in _timings[context])
421
+ total_time = sum(elapsed for _, _, elapsed in sorted_timings)
381
422
  quick_print(f"Total execution time: {total_time:.6f}")
382
423
 
383
424
  if _block_timings:
@@ -390,7 +431,7 @@ def time_code(label=None):
390
431
  sorted_blocks = sorted(_block_timings.items(), key=lambda x: x[1], reverse=True)
391
432
 
392
433
  for block, elapsed in sorted_blocks:
393
- if block not in _ignore_line:
434
+ if not any(ignore in block for ignore in _ignore_line):
394
435
  percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
395
436
  quick_print(f"{block[:40]:40} | {elapsed:12.6f} | {percentage:10.2f}%")
396
437
 
@@ -399,6 +440,8 @@ def time_code(label=None):
399
440
  # Clear the timing data for this context
400
441
  del _timings[context]
401
442
  _block_timings.clear()
443
+ _seen_lines.clear()
444
+ _function_lines.clear()
402
445
 
403
446
  class k:
404
447
  pass
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.1
2
+ Name: kenenet
3
+ Version: 1.0.2
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=d_aoiuWc_W3n6EjhjO0F6hydgHGIRgfcoyQUncwt5q8,18756
2
+ kenenet-1.0.2.dist-info/METADATA,sha256=IsbHQJCapu7AprwiYN_28jB-iAwdZfV8eNwmLkngygA,1693
3
+ kenenet-1.0.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
+ kenenet-1.0.2.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
+ kenenet-1.0.2.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: kenenet
3
- Version: 1.0.0
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=ItADdK783GGIT5lJiBRAH-5u4xt7Gnx7Sq0J65ymHWU,16430
2
- kenenet-1.0.0.dist-info/METADATA,sha256=Bso5PLesPCvPKb1ZTdIA7mDORJoE7qdAREsBP89DSYU,633
3
- kenenet-1.0.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
- kenenet-1.0.0.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
- kenenet-1.0.0.dist-info/RECORD,,