Skip to content

Trigger cf workflow #35

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

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from
Draft

Trigger cf workflow #35

wants to merge 40 commits into from

Conversation

KRRT7
Copy link
Collaborator

@KRRT7 KRRT7 commented Jul 25, 2025

No description provided.

adtyavrdhn and others added 30 commits July 21, 2025 22:52
…sage part instead of stringifying (pydantic#2173)

Co-authored-by: Douwe Maan <[email protected]>
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
codeflash-ai bot added a commit that referenced this pull request Jul 25, 2025
…`trigger-cf-workflow`)

Here is an optimized version of your Python program. Major optimizations.

- Caches the result of `guess_type` per unique URL using `functools.lru_cache`, which reduces repeated MIME type computations (especially on large scale repeated calls).
- Since the class is supposed to inherit from `FileUrl`, it is best to avoid repeating the dataclass and repr decorators if already present in the parent (maintaining runtime correctness and consistency).
- Removed imports that are not used in this file to reduce module loading time.
- The code preserves all functionality and the original function signatures.



#### Notes.
- The `_guess_type_cached` helper is a staticmethod, so it's shared across all instances and efficiently caches guess_type results.
- If your usage pattern always has unique URLs, set `maxsize=None` to cache unlimited.
- This optimization especially benefits use-cases where the same URL may have its media-type inferred more than once.  
- The `dataclass` and `repr` decorators are *not required* here because `FileUrl` already establishes the base data model and behaviors for you.
Copy link

codeflash-ai bot commented Jul 25, 2025

⚡️ Codeflash found optimizations for this PR

📄 12% (0.12x) speedup for DocumentUrl._infer_media_type in pydantic_ai_slim/pydantic_ai/messages.py

⏱️ Runtime : 23.8 milliseconds 21.3 milliseconds (best of 30 runs)

I created a new dependent PR with the suggested changes. Please review:

If you approve, it will be merged into this PR (branch trigger-cf-workflow).

@KRRT7 KRRT7 force-pushed the trigger-cf-workflow branch from eee4872 to dddb328 Compare July 29, 2025 02:33
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.