-
Notifications
You must be signed in to change notification settings - Fork 565
PYTHON-1309 cqlengine: Remove deepcopy on UserType deserialization #1192
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
PYTHON-1309 cqlengine: Remove deepcopy on UserType deserialization #1192
Conversation
This change makes it so newly instanced UserType during deserialization isn't immediately copied by deepcopy, which could cause huge slowdown if that UserType contains a lot of data or nested UserTypes, in which case the deepcopy calls would cascade as each to_python call would eventually clone parts of source object. As there isn't a lot of information on why this deepcopy is here in the first place this change could potentially break something. Running integration tests against this commit does not produce regressions, so this call looks safe to remove, but I'm leaving this warning here for the future reference. Issue: scylladb#152
fruch
commented
Dec 13, 2023
@absurdfarce you think someone would be able to take a look at this one ? (there was no response on the related issue: https://datastax-oss.atlassian.net/browse/PYTHON-1309)
Thanks for the PR @k0machi! Apologies, this somehow completely slipped past me when it first came in.
Have you signed the Contributor License Agreement for contributions to DataStax open source projects? If not you can find it at https://cla.datastax.com/. Thanks!
fruch
commented
Jun 19, 2025
Thanks for the PR @k0machi! Apologies, this somehow completely slipped past me when it first came in.
Have you signed the Contributor License Agreement for contributions to DataStax open source projects? If not you can find it at https://cla.datastax.com/. Thanks!
@k0machi from my team in scylladb, a cla still needed ?
Also we have this change for quite some time in our fork, no with issues (so far...)
Ah, sorry, I didn't realize that @fruch ... if that's the case then no, we're good.
fruch
commented
Jul 4, 2025
Ah, sorry, I didn't realize that @fruch ... if that's the case then no, we're good.
Next time I'll tell him to be more vocal about where he's from 😜
Uh oh!
There was an error while loading. Please reload this page.
This change makes it so newly instanced UserType during deserialization isn't immediately copied by deepcopy, which could cause huge slowdown if that UserType contains a lot of data or nested UserTypes, in which case the deepcopy calls would cascade as each to_python call would eventually clone parts of source object. As there isn't a lot of information on why this deepcopy is here in the first place this change could potentially break something. Running integration tests against this commit does not produce regressions, so this call looks safe to remove, but I'm leaving this warning here for the future reference.
Issue: scylladb#152
Issue (upstream): PYTHON-1309
Here are flamegraphs for an application that uses cqlengine and encounters this issue:
Before
profile-1
After
profile2
The request time goes from 10 seconds in this case down to 750ms, for reference the table is configured with a list of UserTypes that have a list of another UserType inside them.