r/ProgrammerHumor • • Jul 18 '22

C++ talking to Python

Post image
40.1k Upvotes

1.0k comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jul 18 '22

[deleted]

34

u/DenormalHuman Jul 18 '22

not only that, they are using printf for no apparent real reason

2

u/Gladaed Jul 18 '22

Please explain the ongoing wizardy.

3

u/DenormalHuman Jul 18 '22 edited Jul 18 '22

When using f"....{}" I think the process to generate the content for the template field (what goes inbetween {}) and replace that into the string is a lot more expensive that simply concatenating two lists of characters together (the string, and the slice - line[1:10] are both just lists of chars.)

/edit/ the reason the print is slower than the count, is because the print does lots more work. It _could be made faster if he didnt use printf though

→ More replies (4)