Azure / azure-functions-python-library

Azure Functions Python SDK
MIT License
151 stars 63 forks source link

Performance tweaks for to_camel_case #131

Closed pamelafox closed 2 years ago

pamelafox commented 2 years ago

This PR includes two performance tweaks for the to_camel_case function:

1) It replaces the generator expression passed to str.join() with a list comprehension. The list comprehension is actually 10-15% faster as str.join() turns its arguments into a list anyway (if they're not already). More details in this benchmark test: https://github.com/tonybaloney/anti-patterns/pull/4

2) It removes the re.IGNORECASE flag and instead specifies a-zA-Z instead of a-z. That seems to be 20-25% faster according to benchmark in https://github.com/tonybaloney/anti-patterns/pull/5

codecov[bot] commented 2 years ago

Codecov Report

Merging #131 (cc1101d) into dev (6271020) will decrease coverage by 4.04%. The diff coverage is 100.00%.

:exclamation: Current head cc1101d differs from pull request most recent head e283dd1. Consider uploading reports for the commit e283dd1 to get more accurate results

@@            Coverage Diff             @@
##              dev     #131      +/-   ##
==========================================
- Coverage   90.09%   86.04%   -4.05%     
==========================================
  Files          51       50       -1     
  Lines        2959     2903      -56     
  Branches      396      391       -5     
==========================================
- Hits         2666     2498     -168     
- Misses        218      329     +111     
- Partials       75       76       +1     
Flag Coverage Δ
unittests 86.01% <100.00%> (-4.05%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
azure/functions/decorators/utils.py 97.46% <100.00%> (ø)
azure/functions/queue.py 50.79% <0.00%> (-44.45%) :arrow_down:
azure/functions/http.py 53.94% <0.00%> (-30.27%) :arrow_down:
azure/functions/cosmosdb.py 74.35% <0.00%> (-25.65%) :arrow_down:
azure/functions/eventhub.py 69.46% <0.00%> (-19.09%) :arrow_down:
azure/functions/kafka.py 79.85% <0.00%> (-11.95%) :arrow_down:
azure/functions/durable_functions.py 83.33% <0.00%> (-3.04%) :arrow_down:
azure/functions/servicebus.py 83.85% <0.00%> (-2.09%) :arrow_down:
azure/functions/_http.py 91.30% <0.00%> (-1.74%) :arrow_down:
azure/functions/decorators/function_app.py 98.67% <0.00%> (-0.73%) :arrow_down:
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6271020...e283dd1. Read the comment docs.