Coder Social home page Coder Social logo

Comments (11)

fabianp avatar fabianp commented on August 29, 2024

yes that's a bug. Thanks for filling the issue.

from memory_profiler.

jonasc avatar jonasc commented on August 29, 2024

I still see that it does not work for generator functions (version 0.41 from pip). Can it be fixed?

from memory_profiler.

fabianp avatar fabianp commented on August 29, 2024

It should work, there are even some tests for this case. What is the error / failure?

from memory_profiler.

jonasc avatar jonasc commented on August 29, 2024

Consider the following code:

from memory_profiler import profile

@profile
def gen():
    yield 1
    yield 2
    return 3

@profile
def stuff():
    x = yield from gen()
    print('>', x)

print(list(stuff()))

Running it gives the following output (without any profiling output)

$ python -m memory_profiler test.py
> 3
[1, 2]

from memory_profiler.

fabianp avatar fabianp commented on August 29, 2024

We don't support the new "yield from" syntax unfortunately. Patches welcome
:-)

(BTW don't import profile if you run with "-m memory_profiler", it can have
bad side effects)

On Tue, Jul 19, 2016 at 3:20 PM, jonasc [email protected] wrote:

Consider the following code:

from memory_profiler import profile
@profiledef gen():
yield 1
yield 2
return 3
@profiledef stuff():
x = yield from gen()
print('>', x)
print(list(stuff()))

Running it gives the following output (without any profiling output)

$ python -m memory_profiler test.py

3
[1, 2]


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/fabianp/memory_profiler/issues/42#issuecomment-233629778,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAQ8h5EkTaKuk-KmyE16QxPwcaV94LGPks5qXM8WgaJpZM4AjmU_
.

from memory_profiler.

astrojuanlu avatar astrojuanlu commented on August 29, 2024

Change the title to "does not work with coroutines"? :)

from memory_profiler.

yarikoptic avatar yarikoptic commented on August 29, 2024

what am I dong wrong?

$> cat script2.py
import memory_profiler as mp
print(mp.__version__)
from memory_profiler import profile

@profile
def my_func():
    a = [1] * (10 ** 6)
    b = [2] * (2 * 10 ** 7)
    yield b
    del b
    yield a

for f in my_func():
   print('.')

$> python -m memory_profiler script2.py
0.52.0
.
.

from memory_profiler.

wowkin2 avatar wowkin2 commented on August 29, 2024

Any progress on that?

from memory_profiler.

delijati avatar delijati commented on August 29, 2024

#255

from memory_profiler.

Templarrr avatar Templarrr commented on August 29, 2024

Still see this problem with generators (not coroutines) both in py2 and py3 in my code. profile wrapper just outputs nothing

E.g. script

from memory_profiler import profile

@profile
def gen():
    for i in range(100):
        yield i

@profile
def func1():
    return [i for i in gen()]

@profile
def func2():
    return list(range(100))

assert func1() == func2()

outputs for func2 and func1but nothing for gen

from memory_profiler.

luizoti avatar luizoti commented on August 29, 2024

The problem persistis, python 3.11.

from memory_profiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.