Re: Why I fail so bad to check for memory leak with this code?

2022-07-21 Thread MRAB
On 21/07/2022 23:39, Marco Sulla wrote: I've done this other simple test: #!/usr/bin/env python3 import tracemalloc import gc import pickle tracemalloc.start() snapshot1 = tracemalloc.take_snapshot().filter_traces(     (tracemalloc.Filter(True, __file__), ) ) for i in range(1000):     pi

Re: Why I fail so bad to check for memory leak with this code?

2022-07-21 Thread Marco Sulla
I've done this other simple test: #!/usr/bin/env python3 import tracemalloc import gc import pickle tracemalloc.start() snapshot1 = tracemalloc.take_snapshot().filter_traces( (tracemalloc.Filter(True, __file__), ) ) for i in range(1000): pickle.dumps(iter([])) gc.collect() snapsh

RE: Resolving Weekday Schedules to Dates

2022-07-21 Thread avi.e.gross
Do you know of a library that resolves schedules like every Wednesday at 3:00pm to absolute time, that is return the datetime of the next occurrence? It may be as simple, as this to add seven days, assuming a slip of a second is not important or even a hour when things change. Enddate = Beg

Re: Why I fail so bad to check for memory leak with this code?

2022-07-21 Thread Marco Sulla
This naif code shows no leak: import resource import pickle c = 0 while True: pickle.dumps(iter([])) if (c % 1) == 0: max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss print(f"iteration: {c}, max rss: {max_rss} kb") c += 1 -- https://mail.python.org/

Re: Why I fail so bad to check for memory leak with this code?

2022-07-21 Thread Marco Sulla
On Thu, 21 Jul 2022 at 22:28, MRAB wrote: > > It's something to do with pickling iterators because it still occurs > when I reduce func_76 to: > > @trace > def func_76(): > pickle.dumps(iter([])) It's too strange. I found a bunch of true memory leaks with this decorator. It seems to be relia

Re: Why I fail so bad to check for memory leak with this code?

2022-07-21 Thread MRAB
On 21/07/2022 20:47, Marco Sulla wrote: I tried to check for memory leaks in a bunch of functions of mine using a simple decorator. It works, but it fails with this code, returning a random count_diff at every run. Why? import tracemalloc import gc import functools from uuid import uuid4 import

Re: Resolving Weekday Schedules to Dates

2022-07-21 Thread jkn
On Thursday, July 21, 2022 at 8:19:34 PM UTC+1, rambius wrote: > Hello, > > Do you know of a library that resolves schedules like every Wednesday > at 3:00pm to absolute time, that is return the datetime of the next > occurrence? > > Regards > rambius > > P.S. > > -- > Tangra Mega Rock:

Why I fail so bad to check for memory leak with this code?

2022-07-21 Thread Marco Sulla
I tried to check for memory leaks in a bunch of functions of mine using a simple decorator. It works, but it fails with this code, returning a random count_diff at every run. Why? import tracemalloc import gc import functools from uuid import uuid4 import pickle def getUuid(): return str(uuid

Re: Resolving Weekday Schedules to Dates

2022-07-21 Thread Skip Montanaro
> Do you know of a library that resolves schedules like every Wednesday > at 3:00pm to absolute time, that is return the datetime of the next > occurrence? Take a look at the `rrule` module in the `dateutil` package: https://dateutil.readthedocs.io/en/stable/rrule.html Skip -- https://mail.pyth

Resolving Weekday Schedules to Dates

2022-07-21 Thread Ivan "Rambius" Ivanov
Hello, Do you know of a library that resolves schedules like every Wednesday at 3:00pm to absolute time, that is return the datetime of the next occurrence? Regards rambius P.S. -- Tangra Mega Rock: http://www.radiotangra.com -- https://mail.python.org/mailman/listinfo/python-list

Re: exec() an locals() puzzle

2022-07-21 Thread george trojan
Thanks. That cdef-locals concept is consistent with the following example: def f(): i = 1 def g(): print('i' in globals(), 'i' in locals()) def h(): print('i' in globals(), 'i' in locals()); i g() h() f() False False False True It is a mystery, which may be why the documentat

Re: list indices must be integers or slices, not str

2022-07-21 Thread Frank Millman
On 2022-07-20 4:45 PM, Chris Angelico wrote: On Wed, 20 Jul 2022 at 23:50, Peter Otten <__pete...@web.de> wrote: I found https://peps.python.org/pep-3101/ """ PEP 3101 – Advanced String Formatting ... An example of the ‘getitem’ syntax: "My name is {0[name]}".format(dict(name='Fred')) It sh