Comments (11)
yes that's a bug. Thanks for filling the issue.
from memory_profiler.
I still see that it does not work for generator functions (version 0.41 from pip). Can it be fixed?
from memory_profiler.
It should work, there are even some tests for this case. What is the error / failure?
from memory_profiler.
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.
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.
Change the title to "does not work with coroutines"? :)
from memory_profiler.
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.
Any progress on that?
from memory_profiler.
from memory_profiler.
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.
The problem persistis, python 3.11.
from memory_profiler.
Related Issues (20)
- How to test memory usage for a time-loop function?
- Inconsistent result between line profiler and plot
- The @profile decorator will profile another decorator when chaining multiple decorators into a function. HOT 1
- include-children in decorator
- do not work in python 3.11 HOT 3
- Is maintained or not? HOT 4
- [BUG] invalid non-printable character U+FEFF HOT 6
- After delete the snapshot file, the function cannot be used when the memory profiler is opened again
- mprof: error: unrecognized arguments: --backend
- AttributeError: module 'pylab' has no attribute 'ioff' (Python 3.9) HOT 2
- Adding "--" to argment list may change the argument of the program started by `mprof run`. HOT 2
- non-ascii source characters misprocessed (maybe through 8859?) HOT 3
- mem usage and increment print is missing HOT 2
- I'm a beginner in the world of developing, I just finished learning python and html and css what's the next step please?I need a help with that. HOT 1
- Is it possible to compare two plots? HOT 1
- negative memory increment
- Is there a specific reason memory_usage return None when stream=True ? HOT 1
- Inconsistent documentation of units
- not sure how to interpret these results
- `tracemalloc` `backend` broken for `memory_usage`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memory_profiler.