Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: shallow copy instead of deepcopy #197

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from perception_eval.common.transform import TransformDict
from perception_eval.evaluation import DynamicObjectWithPerceptionResult
from perception_eval.evaluation.matching import MatchingMode

from copy import copy

def filter_object_results(
object_results: List[DynamicObjectWithPerceptionResult],
Expand Down Expand Up @@ -123,7 +123,7 @@ def filter_object_results(
is_target = False

if is_target:
filtered_object_results.append(object_result)
filtered_object_results.append(copy(object_result))

return filtered_object_results

Expand Down Expand Up @@ -198,7 +198,7 @@ def filter_objects(
transforms=transforms,
)
if is_target:
filtered_objects.append(object_)
filtered_objects.append(copy(object_))
return filtered_objects


Expand Down
4 changes: 2 additions & 2 deletions perception_eval/perception_eval/tool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from copy import deepcopy
from copy import deepcopy, copy
from enum import Enum
from typing import Any
from typing import Dict
Expand Down Expand Up @@ -475,7 +475,7 @@ def filter_frame_by_distance(
Returns:
PerceptionFrameResult: Filtered frame results.
"""
ret_frame = deepcopy(frame)
ret_frame = copy(frame)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktro2828 Do you remember why you used deepcopy here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used deepcopy in order to guarantee copying the all objects contained in PerceptionFrameResult.
But I think it is OK to use copy instead if it is OK.


if min_distance is not None:
min_distance_list = [min_distance] * len(ret_frame.target_labels)
Expand Down
Loading