Skip to content

Detail: type naming convention #1016

@dean0x7d

Description

@dean0x7d

In the pybind11 detail code, we have 3 different kinds of type information:

  1. C++ RTTI: std::type_info
  2. Python's PyTypeObject
  3. pybind11's extended type information: detail::type_info

The variable naming scheme for these 3 kinds of type info objects isn't currently very consistent. type, tinfo, type_info, etc. are used interchangeably for all 3 kinds of type info, which can cause confusion (at least it does for me). And as I've recently found in #1014, it can result in some unfortunate expressions like x.type->type (where the second type isn't a Python-style metatype, it's just a different kind of type object).

I'd like to propose a naming convention for these objects (especially when they are members):

  1. std::type_info: variables named cpptype (already in use, but only partially).
  2. PyTypeObject: pytype.
  3. detail::type_info: it would be nice to rename the type to detail::extended_type (to avoid confusion with std::type_info) and name variables like ext_type or et.

What do you think? Does it make sense or am I just bikeshedding?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions