Commit 05c4f51
authored
Optimize ensure_str and ensure_binary. (#331)
We found that large applications that have undergone a 2 -> 3 migration
and wound up with a lot of six.ensure_str and six.ensure_binary calls
could save 1-2% CPU usage by optimizing these for the common case.
Further optimization could be done by replacing them with extension
module implementations - assumed out of scope for the pure Python six
project itself.
Ideally all of these calls and use of six in people's code would be
removed after there all need for any Python 2 compatibility is gone.
But completing that kind of type cleanup requires a lot of human
engineering time. This lowers the ongoing costs in the interim.
Contributed by YouTube.1 parent a5bb7aa commit 05c4f51
1 file changed
+10
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
| 893 | + | |
| 894 | + | |
893 | 895 | | |
894 | 896 | | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
| 897 | + | |
899 | 898 | | |
900 | 899 | | |
901 | 900 | | |
| |||
909 | 908 | | |
910 | 909 | | |
911 | 910 | | |
912 | | - | |
913 | | - | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
914 | 914 | | |
915 | | - | |
| 915 | + | |
916 | 916 | | |
917 | | - | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
918 | 920 | | |
919 | 921 | | |
920 | 922 | | |
| |||
0 commit comments