Skip to content

Replace reshape(-1,) with ravel() for faster flattening #14

@SaFE-APIOpt

Description

@SaFE-APIOpt

radial_distortion = np.array([K1, K2]).reshape(-1,)

Current code:
radial_distortion = np.array([K1, K2]).reshape(-1,)
Proposed replacement:
radial_distortion = np.array([K1, K2]).ravel()
Both reshape(-1,) and ravel() flatten arrays into 1-D.

Performance: ravel() is consistently faster than reshape(-1,), as it avoids extra shape compatibility checks.

Robustness: ravel() directly returns a view when possible, and only falls back to a copy if required, whereas reshape(-1,) requires the array to be contiguous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions