Brandon Rhodes - Oh, Come On Who Needs Bytearrays - PyCon 2015

Поділитися
Вставка
  • Опубліковано 4 лис 2024

КОМЕНТАРІ • 15

  • @pablolucena4336
    @pablolucena4336 4 роки тому +3

    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!

  • @austecon6818
    @austecon6818 4 роки тому +1

    what a great talk! thank you!

  • @AlSweigartDotCom
    @AlSweigartDotCom 5 років тому +4

    The parentheses tax is something I'm fully willing to pay for the savings in braces that Python gives me. :)

  • @pythonrocks
    @pythonrocks 9 років тому +4

    bytearray vs str reminds me of Java's StringBuffer vs String.

  • @DustinRodriguez1_0
    @DustinRodriguez1_0 9 років тому +6

    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
      @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
      @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)?

  • @driziiD
    @driziiD 4 роки тому

    everything is arrays

  • @sohangchopra6478
    @sohangchopra6478 3 роки тому +1

    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
      @Ca1vema 2 роки тому

      Thanks for the tip, i'll just spend another 2 years mastering c++ and then maybe I'll get a working programm.

  • @milesrout
    @milesrout 8 років тому +2

    bytearray isn't a mutable string. It's not a string. It's an array.

    • @Pille1842
      @Pille1842 7 років тому +1

      Miles Rout A string is an array of bytes.

    • @milesrout
      @milesrout 7 років тому +2

      No

    • @Pille1842
      @Pille1842 7 років тому +1

      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
      @milesrout 7 років тому +4

      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*.