Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Week04/decorators_besir_secilmis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import tracemalloc
import time

def performance(func):
performance.counter = 0
performance.total_time = 0.0
performance.total_mem = 0.0

def wrapper(*args, **kwargs):
tracemalloc.start()
start_time = time.time()
result = func(*args, **kwargs)
end_time = time.time()
current, peak = tracemalloc.get_traced_memory()
tracemalloc.stop()
performance.counter += 1
performance.total_time += (end_time - start_time)
performance.total_mem += peak
return result
return wrapper
27 changes: 27 additions & 0 deletions Week04/functions_besir_secilmis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
custom_power = lambda x = 0 , / , e = 1 : x**e

def custom_equation(x: int = 0 , y: int = 0 , / , a: int = 1 , b: int = 1 , * , c: int = 1 ) -> float:
"""
This function calculates a custom equation with the given five integers.

:param x: First base value
:param y: Second base value
:param a: Exponent of variable x
:param b: Exponent of variable y
:param c: Divisor value
:return: The float result of the operation
"""

return (x**a + y**b) / c

def fn_w_counter() -> (int, dict[str, int]):
if not hasattr(fn_w_counter,'call_counter'):
fn_w_counter.call_counter = 0
fn_w_counter.caller_dict = {}
caller = __name__
fn_w_counter.call_counter += 1
if caller in fn_w_counter.caller_dict:
fn_w_counter.caller_dict[caller] += 1
else:
fn_w_counter.caller_dict[caller] = 1
return fn_w_counter.call_counter,fn_w_counter.caller_dict
5 changes: 5 additions & 0 deletions Week05/awaitme_besir_secilmis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def awaitme(func):
async def wrapper(*args,**kwargs):
result = func(*args,**kwargs)
return result
return wrapper
Loading