Skip to content

classmethod_descriptor #4690

Closed
Closed

Description

@seungha-kim

Feature

# In CPython
>>> type(dict.__dict__["fromkeys"])
<class 'classmethod_descriptor'>
>>> type(dict.fromkeys)
<class 'builtin_function_or_method'>

# In RustPython
>>>>> type(dict.__dict__["fromkeys"])
<class 'classmethod'>
>>>>> type(dict.fromkeys)
<class 'builtin_function_or_method'>
  • <class 'classmethod'> is for descriptors of Python-side @classmethod.
    • PyClassMethod_Type in CPython
    • PyClassMethod in RustPython
  • <class 'classmethod_descriptor'> is for descriptors of native-side class method.
    • PyClassMethodDescr_Type in CPython
    • Nothing in RustPython, instead using PyClassMethod

(Yeah, these names are somewhat confusing...)

In short, RustPython uses a different type from CPython for built-in class methods.

I don't know if it causes any real difference in behavior. There is no test for this in CPython (only a mysterious comment exists)

Python Documentation

No documents were found.

Activity

  1. youknowone commented on Mar 15, 2023

    @youknowone
    Member

    That's a sort of optimization detail. Once we try similar optimization, we will get it too. are you interested in it? I can explain more about it.

  2. seungha-kim commented on Mar 15, 2023

    @seungha-kim
    ContributorAuthor

    Sure. #4686 makes me look into it :)

  3. youknowone commented on Oct 6, 2026

    @youknowone
    Member

    The originally reported problem no longer reproduces on current main. Closing per the recheck in #8982.

    — commented by Grok 4.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions