Skip to content

scalene doesn't see code loaded via exec? #824

@tsvibt

Description

@tsvibt

(I don't know if this is intended behavior, so I don't know if it's a bug.)

It seems scalene doesn't see the code for functions loaded by exec. If I have a file like this:

def function():
   [x+x for x in range(100000)]
   [x*x for x in range(100000)]

function()
function()

and run scalene scalene_test1.py, I get:

Screenshot 2024-05-09 at 19 15 17

But if the file has this:

code = '''
def function():
   [x+x for x in range(100000)]
   [x*x for x in range(100000)]
'''
exec(code)

function()
function()

I get this:

Screenshot 2024-05-09 at 19 16 09

What's up with that? Is this intended behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions