You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MNT]: macOS backend uses un-prefixed class names #31813
Currently, the macOS backend defines the following four Objective-C classes:
Name
Superclass
Python Owner
Window
NSWindow
FigureManager
View
NSView
FigureCanvas
MatplotlibAppDelegate
NSObject
-
NavigationToolbar2Handler
NSObject
NavigationToolbar2
Officially, per Apple Conventions: "your own classes should use three-letter prefixes".
In practice, un-prefixed names like "Window" or "View" are commonly used inside of application code. Inside of framework code, however, they would cause naming conflicts.
The macOS matplotlib backend is an unusual hybrid of a Python framework that then masquerades as an app. As such, it probably makes sense to prefix our classes (either with a standard three-letter abbreviation like MPL or with a full-name prefix like "Matplotlib").
That said, the un-prefixed names seemingly haven't conflicted with anything in over a decade.
I don't think this is really API that we expose otherwise, so we are probably free to rename it at any point. I don't know if there's really a strong impetus to do the change, though.
@QuLogic - The issue isn't that we expose the API, it's that it could conflict with other frameworks or apps. Right now, if the Python process running matplotlib loads some other executable code with a class called "Window", you will see this:
Class Window is implemented in both /path/to/Foo.framework and
/path/to/_macosx.cpython-314-darwin.so. One of the two will be used. Which one is undefined.
If you are writing an Obj-C application, it's fine to not use a prefix (although technically it's in violation of Apple's guidelines). However, anything loadable into a process should be prefixed with two letters if you are Apple, or three letters if you are anyone else.
Note that there's a few historic outliers, WebKit use to use the "Web" prefix before moving to "WK".
Activity
QuLogic commentedon Jun 16, 2026
I don't think this is really API that we expose otherwise, so we are probably free to rename it at any point. I don't know if there's really a strong impetus to do the change, though.
iccir commentedon Jun 16, 2026
@QuLogic - The issue isn't that we expose the API, it's that it could conflict with other frameworks or apps. Right now, if the Python process running matplotlib loads some other executable code with a class called "Window", you will see this:
If you are writing an Obj-C application, it's fine to not use a prefix (although technically it's in violation of Apple's guidelines). However, anything loadable into a process should be prefixed with two letters if you are Apple, or three letters if you are anyone else.
Note that there's a few historic outliers, WebKit use to use the "Web" prefix before moving to "WK".