Skip to content

Performance Issue with Extracting genres Attribute from Media #1449

@sqkkyzx

Description

@sqkkyzx

Describe the Bug

For the following code snippet, I observed a significant performance discrepancy:

logging.info(F"movie count: {len(movies)}")

# test1
test1_start = time.time()
for movie in movies:
    logging.debug(f"{movie.__dict__.get('genres')}")
logging.info(f"duration {time.time()-test1_start}")

# test2
test2_start = time.time()
for movie in movies:
    logging.debug(f"{movie.genres}")
logging.info(f"duration {time.time()-test2_start}")

The output is:

INFO:root:movie count: 115
INFO:root:duration 0.0010001659393310547
INFO:root:duration 7.938525915145874

This is horrifying.

Code Snippets

No response

Expected Behavior

No response

Additional Context

No response

Operating System and Version

windows server 2022

Plex Media Server Version

1.40.4.8679

Python Version

3.12

PlexAPI Version

4.15.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions