I’m curious which form is more efficient, is correct style, etc. I feel like the “.0” approach is much quicker; I’m not sure why the “float” approach is equally appreciated (if it is).
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using
float(7)adds some unnecessary overhead—Python has to find thefloatfunction inglobals()and call it. Using7.0does all the necessary conversions at compile-time instead of run-time. You can see this using the Python bytecode disassembler.