0

ImageExplainingALot

I saw these function definitions in the list class (although these types of definitions are everywhere)

I first thought that the sort function of list would've been a bubble or a selective sort, but its a ...!

I understand almost every other thing in these definitions, but the ... after : and in the arguements confuses me

any explainations?

  • "I saw these function definitions in the list class" How *exactly* did you see them? the builtins do *not* have available Python source in the reference implementation. They are *not implemented in Python* in the reference implementation. – Karl Knechtel Jul 19 '21 at 06:27
  • I ctrl clicked the function `sort` in vscode, and it took me here –  Jul 19 '21 at 06:28
  • 4
    Then, this is a pseudo-implementation (or defintion) provided by vscode, in its own notation, and the best way to understand it is via the vscode documentation. – Karl Knechtel Jul 19 '21 at 06:31
  • For the Python sort algorithm Python uses, look at https://stackoverflow.com/questions/10948920. It is neither a bubble sort nor a selection sort. It is also not a `...` because those (rather weird) notations are pseudo-type-hints for the named parameters `key=` (which specifies the sort *order*, not the *algorithm*) and `reverse=` (which is a `bool` that does what you think it does). If you really want to know about how Python does something, go to the Python docs: https://docs.python.org/3/howto/sorting.html Other sources can be oversimplified, misleading, and occasionally downright wrong. – BoarGules Jul 19 '21 at 06:59

0 Answers0