Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't track multidict if it contains untrackable objects only #430

Open
asvetlov opened this issue Dec 11, 2019 · 1 comment
Open

Don't track multidict if it contains untrackable objects only #430

asvetlov opened this issue Dec 11, 2019 · 1 comment

Comments

@asvetlov
Copy link
Member

Multidict is used mostly for storing primitive types as keys and values: str, int, float, None.

PyObject_GC_Track should be called only if a key or value doesn't belong to a primitive type.

BTW, now PyObject_GC_Track is not called for multidicts and proxies which is an error.

@asvetlov
Copy link
Member Author

Sorry, I was wrong.
All MultiDict/CIMultiDict/MultiDictProxy/CIMultiDictProxy use PyType_GenericNew and PyType_GenericAlloc for tp_new/tp_alloc slots.
PyType_GenericAlloc automatically tracks GC if Py_TPFLAGS_HAVE_GC flag is set.

Explicit managing still makes sense as a microoptimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant