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

Avoid copying frozendicts #8

Merged
merged 1 commit into from
Mar 29, 2018
Merged

Avoid copying frozendicts #8

merged 1 commit into from
Mar 29, 2018

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Mar 28, 2018

It's not cheap.

(includes #7)

Copy link
Member

@erikjohnston erikjohnston left a comment

Choose a reason for hiding this comment

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

I'm wondering if we should have a third default encoder that doesn't handle frozendicts, which can be used when we've set the synapse.events.USE_FROZEN_DICTS to False? I'm not sure if we use frozendicts elsewhere.

I guess the overhead of default isn't high if it never encounters a frozendict?

It's not cheap.
@richvdh richvdh force-pushed the rav/no_copy_frozendict branch from 0a9f850 to e1fe5ea Compare March 29, 2018 13:59
@richvdh
Copy link
Member Author

richvdh commented Mar 29, 2018

I guess the overhead of default isn't high if it never encounters a frozendict?

I really don't think so. It's only called if simplejson doesn't recognise the type being serialised, so unless we have frozendicts it will never be called (or rather, if it is, it's on an unrecognised type which is going to fail anyway).

So I don't think it's worth having another encoder.

@richvdh richvdh merged commit c94529a into master Mar 29, 2018
@richvdh richvdh deleted the rav/no_copy_frozendict branch March 29, 2018 14:03
richvdh added a commit that referenced this pull request Apr 13, 2018
Since #8, we poke directly into frozendict._dict; it turns out this has only
existed since 1.0.
@richvdh richvdh restored the rav/no_copy_frozendict branch June 4, 2018 08:10
@clokep clokep deleted the rav/no_copy_frozendict branch September 23, 2022 15:00
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

Successfully merging this pull request may close these issues.

2 participants