Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make "struct _Py_dict_state" a little more compact.
  • Loading branch information
ericsnowcurrently committed Nov 16, 2022
commit f684dcd7a0f4ae0c31630905e9f81bcd1ac975f9
2 changes: 1 addition & 1 deletion Include/internal/pycore_dict_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct _Py_dict_state {
#if PyDict_MAXFREELIST > 0
/* Dictionary reuse scheme to save calls to malloc and free */
PyDictObject *free_list[PyDict_MAXFREELIST];
int numfree;
PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST];
int numfree;
int keys_numfree;
Comment on lines +35 to +38
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about reorder members to make struct compact?

Suggested change
PyDictObject *free_list[PyDict_MAXFREELIST];
int numfree;
PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST];
int keys_numfree;
PyDictObject *free_list[PyDict_MAXFREELIST];
PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST];
int numfree;
int keys_numfree;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind doing that, but it isn't much related to this PR and I was trying to minimize extra changes. That said, it is a fairly small and simple change so I'll go ahead and do it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#endif
PyDict_WatchCallback watchers[DICT_MAX_WATCHERS];
Expand Down