Skip to content

Conversation

@ryanking13
Copy link
Contributor

Related: #5678

We would like to make a small breaking change in Python, but it seems like currently importing compat flags are only available in the JS code for Python workers.

This PR enables importing compat flags from python code of Python workers such as

import _cloudflare_compat_flags
_cloudflare_compat_flags.python_workflows

This PR includes updating the custom serializer for the snapshot as the compat flag object is exposed as a global object.

@ryanking13 ryanking13 requested review from a team as code owners December 17, 2025 09:27
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 17, 2025

CodSpeed Performance Report

Merging #5713 will not alter performance

Comparing python-compat-flag (aa88098) with main (1a4a798)

Summary

✅ 140 untouched
⏩ 38 skipped1

Footnotes

  1. 38 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@ryanking13 ryanking13 requested a review from hoodmane December 18, 2025 04:08
@ryanking13 ryanking13 force-pushed the python-compat-flag branch 3 times, most recently from 1152c07 to 1a46099 Compare January 2, 2026 08:52
Copy link
Contributor

@dom96 dom96 left a comment

Choose a reason for hiding this comment

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

Code changes look good.

One question I have is how does this interact with our baseline snapshots? We have to be careful to not serialise the compat flags in that snapshot as it could then cause issues.

@ryanking13
Copy link
Contributor Author

One question I have is how does this interact with our baseline snapshots? We have to be careful to not serialise the compat flags in that snapshot as it could then cause issues.

What I thought was that because this uses a custom serializer, the compat flags will pick up the fresh, user-passed flags when deserializing the snapshot. @hoodmane Could you confirm that I am understanding it correctly?

@hoodmane
Copy link
Contributor

hoodmane commented Jan 2, 2026

That's right. Though if you say a = compat_flags.foo then obviously that is not going to be updated.

Copy link
Contributor

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@ryanking13 ryanking13 merged commit e46f4d8 into main Jan 5, 2026
20 of 21 checks passed
@ryanking13 ryanking13 deleted the python-compat-flag branch January 5, 2026 07:57
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.

3 participants