Skip to content

[PERF] Construction of known cdef classes can go through __new__ #1643

Description

@mdboom

In driver, runtime and nvrtc, when an instance of a cdef class is contructed (usually as a return value), it just uses the obvious Python-level constructor, for example:

cdef CUtensorMap tensorMap = CUtensorMap()

This makes a slow Python-like call (the ironically named PyObject_FastCall).

Instead, following Cythons fast instantiation advice, we can use __new__, which will make a faster C-level call to __cinit__.

cdef CUtensorMap tensorMap = CUtensorMap.__new__(CUtensorMap)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Low priority - Nice to havecuda.bindingsEverything related to the cuda.bindings moduleperformance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions