Comments (11)
I don't know how much of a difference it will make, but the codebase is pretty class-heavy so I'm optimistic
from authentik.
Hey, I wasn't aware that __slots__
makes this much of a difference, I am looking forward to seeing what the PR will bring!
from authentik.
PyPy does some optimisations like this already.
PyPy uses JIT, which generally uses a lot more memory, has slower startup times, but works faster. I'd expect most code running in PyPy to use more memory, unless you're getting to the hundred's of MB range. I'd be pretty surprised is slots helped that much either, definitely I don't think you should apply it to all classes but if there's some class that's getting instantiated thousands of times it would be a good thing to look at optimizing.
Is this project really instantiating thousands and thousands of classes?
from authentik.
There are some classes that are instantiated a lot (especially for the PolicyEngine), but a lot of the other classes use a lot of inheritance.
Most things in this projects are class based, simply just because of django and drf.
from authentik.
Well it will be interesting to see if this has any significant impact
from authentik.
The PyPy comment was based on this page about __slots__
which says PyPy "does these optimisations by default", which I just blindly trusted. Maybe that's totally wrong, I don't know
from authentik.
How __slots__
works is by telling the python interpreter to only expect objects to only contain certain attributes which makes the objects not use dicts to store them in memory. The reason why this has an effect on memory consumption is how the data is structured in memory. It also has an additional benefit of improving the time it takes to get/set the attributes. PyPy does indeed do this by default, it using more memory on average is not indicative of how it will change a project that doesn't use it as PyPy drastically alters the way python operates in other ways (JIT instead of interpreted).
The only downside is you cannot get/set attributes that do not exist in this array and ALL objects in the inheritance chain MAY NOT use dicts for memory storage, i.e. they MUST also define __slots__
. One other piece of information is that __slots__
is inherited also. Technically it's better to allow __slots__
to be inherited, i.e. don't define an attribute twice; however you can do so if you must/desire, it will just use a bit more memory.
from authentik.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from authentik.
I hate stale closing bot. It's the worst bot. I mean don't get my wrong, I don't think adding __slots__
to all classes makes sense, but stale-close bot it still the worst.
from authentik.
I got bored of working on this, so it's fine for stale bot to close it if it wants.
from authentik.
@traverseda My bad, I didn't fully think through configuring stale bot when I initially added it.
I re-opened this issue with a pr_wanted
label, which won't be closed by stale bot, and essentially means its a nice feature/addition, that I don't (currently) plan on adding myself, but I am open to PRs for it.
from authentik.
Related Issues (20)
- Nextcloud AIO unshared files and folders are displayed as "Shared" when account created via Authentik SAML / user_saml
- Failed to export blueprints
- Blueprint does not apply
- GET /api/v3/flows/executor/default-authentication-flow/ HOT 1
- web: Locale setting not respected HOT 3
- Web/Admin: Flow running returns 500 HOT 5
- Outpost doesn't generate any code in Setup HOT 1
- No page showing while accessing from iOS 15 (iPhone 7) HOT 2
- 2024.4.0 LongRunningTransaction HOT 2
- Authentik LDAP authentication
- Can't create app password on 2024.4.0 HOT 1
- Authentik broken after upgrade to version 2024.4.0: Unauthenticated after login HOT 14
- Unable to log into anything after upgrade 2024.2.2 -> 2024.4.0 HOT 1
- Using invitation data in expression policies during prompt validation HOT 3
- Sync groups as members of other groups from LDAP source (Active Directory) / Nested Groups sync.
- GET /api/v3/flows/executor/default-authentication-flow/ HOT 1
- Policy on enrollment no longer working in `2024.4` resulting in `UserSourceConnection has no user.` HOT 3
- Authentik crashing (after Redis timeout)
- Uploading icons to a default install with Docker Compose HOT 1
- Expression policy error `builtins.KeyError: 'flow_plan'` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from authentik.