⚡️ Speed up method OpenAIWhisperAudioTranscriptionConfig.map_openai_params by 70%
          #169
        
          
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
📄 70% (0.70x) speedup for
OpenAIWhisperAudioTranscriptionConfig.map_openai_paramsinlitellm/llms/openai/transcriptions/whisper_transformation.py⏱️ Runtime :
204 microseconds→120 microseconds(best of362runs)📝 Explanation and details
The optimization replaces a linear search approach with set-based operations for parameter filtering. The key changes are:
What was optimized:
supported_params = set(self.get_supported_openai_params(model))converts the supported parameters list to a set for O(1) lookup operationssupported_params.intersection(non_default_params)efficiently finds only the keys that exist in both collectionsif k in supported_paramsfor every parameter, the code now only processes parameters that are guaranteed to be supportedWhy it's faster:
k in supported_paramswas a linear search through the listPerformance characteristics:
test_large_scale_many_unsupported_paramsshows 276% speedup when processing 1000 parameters where only 3 are supportedThis optimization is particularly effective for scenarios with large parameter dictionaries containing mostly unsupported keys, which is common in API parameter filtering.
✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
🔎 Concolic Coverage Tests and Runtime
codeflash_concolic_zbim32de/tmp33s393py/test_concolic_coverage.py::test_OpenAIWhisperAudioTranscriptionConfig_map_openai_paramsTo edit these changes
git checkout codeflash/optimize-OpenAIWhisperAudioTranscriptionConfig.map_openai_params-mhdmo1a7and push.