The parentheses tax is something I'm fully willing to pay for the savings in braces that Python gives me. :)
@pablolucena4336
4 жыл бұрын
It's rare to come by a speaker like Brandon Rhodes. I've learned so much from this single individual throughout the past decade of working with Python. Thanks Brandon!
@DustinRodriguez1_0
9 жыл бұрын
Hmm... += on strings has been optimized for a long time and is generally O(n)... I know the myth that it's O(n**2) persists, but it hasn't been true since 2.6 (maybe 2.5). At least for CPython, it is special-cased. Might not be in PyPy. Teaching people to avoid += for strings should have gone away a long time ago.
@Ca1vema
2 жыл бұрын
the problem with "+", "+=" is that it has to create a copy of the string for each addition operation and that's the reason you should use string interpolation
@mitk01
2 жыл бұрын
Yes += is O(n)... and what happens when you add O(n) operation inside an O(n) loop (which was the case in the presentation)?
@pythonrocks
9 жыл бұрын
bytearray vs str reminds me of Java's StringBuffer vs String.
@austecon6818
4 жыл бұрын
what a great talk! thank you!
@milesrout
8 жыл бұрын
bytearray isn't a mutable string. It's not a string. It's an array.
@Pille1842
7 жыл бұрын
Miles Rout A string is an array of bytes.
@milesrout
7 жыл бұрын
No
@Pille1842
7 жыл бұрын
Well you certainly don't have to take my word for it: "A string is generally understood as a data type and is often implemented as an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding." (en.wikipedia.org/wiki/String_(computer_science))
@milesrout
7 жыл бұрын
Strings in Python are *not* just an array of bytes. They are implemented as an array of bytes, but so is every type in every programming language on a (modern) computer: some number of bytes. Strings in C are *just* an array of bytes that ends in a NUL, but they aren't *just* an array of bytes in Python, they are an array of bytes *with an abstract interface on top*.
@driziiD
4 жыл бұрын
everything is arrays
@sohangchopra6478
3 жыл бұрын
If you really want to squeeze out performance from your computer, then you really should not be using Python in the first place. Use C++ for performance (or C, if you're like Linus Torvalds and hate C++).
@Ca1vema
2 жыл бұрын
Thanks for the tip, i'll just spend another 2 years mastering c++ and then maybe I'll get a working programm.
Пікірлер: 15