GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Unnecessary specialization failures of `LOAD_ATTR` and `STORE_ATTR` when attributes are shadowed by the object's class. · Issue #123040 · python/cpython

Unnecessary specialization failures of LOAD_ATTR and STORE_ATTR when attributes are shadowed by the object's class. #123040

New issue
Copy link
New issue
Copy link
Closed
Closed
Unnecessary specialization failures of LOAD_ATTR and STORE_ATTR when attributes are shadowed by the object's class.#123040
Copy link
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

Description

@markshannon
markshannon
opened on Aug 15, 2024
Issue body actions

This applies to both instances and classes.
If an object and it's class both have attributes with the same name, this prevents specialization of access to the object's attribute.
However, in this case specialization should only be prevented if the class's attribute is a data descriptor.

Example 1, instance:

class C:
    x = 1
    def __init__(self):
        self.x = 2

C().x

C().x above is 2. It doesn't matter that C.x exists, provided it isn't a data descriptor.
This failure shows up as "shadowed" in the stats

Example 2, class:

class Meta(type):
    x = 1
class C(metaclass=Meta):
    x = 1

C.x

C.x is 2. Meta.x doesn't change that, as it isn't a data descriptor.
This failure shows up as "metaclass attribute" in the stats

Linked PRs

  • GH-123040: Specialize shadowed LOAD_ATTR. #123219

Activity

  1. markshannon commented on Aug 15, 2024

    @markshannon
    markshannon
    on Aug 15, 2024
    MemberAuthor
    More actions

    For STORE_ATTR, the failures show up in various ways, depending on the nature of the class's attribute.

  2. markshannon
    changed the title [-]Unnecessary specialization failures of `LOAD_ATTR` and `STORE_ATTR` when attributes are shadowed by the object' class.[/-] [+]Unnecessary specialization failures of `LOAD_ATTR` and `STORE_ATTR` when attributes are shadowed by the object's class.[/+] on Aug 15, 2024
  3. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Aug 16, 2024
  4. picnixz commented on Aug 16, 2024

    @picnixz
    picnixz
    on Aug 16, 2024
    Member
    More actions

    Should this one be categorized as a bug or a feature (AFAICT, it's not really a bug per se, it's just an inefficient path being taken)?

  5. markshannon
    added
    performancePerformance or resource usagePerformance or resource usage
    on Aug 16, 2024
  6. markshannon commented on Aug 16, 2024

    @markshannon
    markshannon
    on Aug 16, 2024
    MemberAuthor
    More actions

    I'll just tag it "performance"

    Reacted by Bénédikt Tran
  7. markshannon
    added
    3.14bugs and security fixesbugs and security fixes
    on Aug 16, 2024
  8. markshannon
    added a commit that references this issue on Aug 23, 2024

    GH-123040: Specialize shadowed `LOAD_ATTR`. (GH-123219)

    5d3201f
  9. markshannon
    closed this as completedon Aug 23, 2024
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

    3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.