mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
fix: penalize local variable caching of globals in ranker prompt
The ranker LLM was rewarding candidates that cache global variables into locals as a performance win. Add an explicit rule: this is only relevant on Python ≤3.10; on 3.11+ LOAD_GLOBAL uses adaptive specialization and is nearly as fast as LOAD_FAST.
This commit is contained in:
parent
c95a36cf38
commit
20ee6d5b62
1 changed files with 1 additions and 0 deletions
|
|
@ -85,6 +85,7 @@ You are also provided with the following information.
|
|||
- Introduction of the `global` and `nonlocal` keywords in optimizations is **HIGHLY DISCOURAGED** as it reduces code clarity and maintainability, introduces hidden dependencies, can cause subtle bugs and breaks modularity. **DO NOT** prefer such optimizations.
|
||||
- Replacement of `isinstance()` checks with `type()` checks is **HIGHLY DISCOURAGED** as `isinstance()` correctly handles inheritance and subclasses, while `type()` checks are incorrect for subclass instances and represent a micro-optimization that should be avoided. Do not prefer such optimizations.
|
||||
- If the only optimizations are micro-optimizations like inlining a function call, or localizing variables or methods (attribute lookup optimizations), do not prefer the optimizations. The performance improvements are minimal and come at a substantial cost to readability.
|
||||
- Local variable caching of globals (e.g., `local_var = GLOBAL_VAR` before a loop) is a micro-optimization only relevant on Python ≤3.10. On Python 3.11+ `LOAD_GLOBAL` uses adaptive specialization and is nearly as fast as `LOAD_FAST`, so the benefit is negligible — prefer the simpler code WITHOUT the local cache.
|
||||
|
||||
## Response Format
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue