Skip to content

[Enh]: Consider adding __slots__ #500

@FBruzzesi

Description

@FBruzzesi

We would like to learn about your use case. For example, if this feature is needed to adopt Narwhals in an open source project, could you please enter the link to it below?

n.a.

Please describe the purpose of the new feature or describe the problem to solve.

To keep the overhead introduced by narwhals objects as low as possible (both in memory and access speed), we could consider using __slots__ since:

  • we don't have dynamic attributes
  • everything falls back to be attribute access and manipulation

If for some use case a library needs to dynamically add attributes to a narwhals object, we can suggest to inherit from the original narwhals implementation.

Suggest a solution if possible.

No response

If you have tried alternatives, please describe them below.

No response

Additional information that may help us understand your needs.

Hard to figure out how to benchmark this

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions