Skip to content

Performance: Reduce refcount churn in csv.reader #156748

Description

@brittanyrey

Minor change to reduce churn in parse_save_field(). It currently calls PyList_Append(self->fields, field); Py_DECREF(field) for every field of every row. PyList_Append internally does Py_NewRef(newitem), so each field pays an incref immediately followed by a decref, plus a critical-section enter/exit.
Since the reference is already about to be dropped, just pass the reference directly to the caller.

(PR is written & ready to attach)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirperformancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions