Inside Python Dict

Learning and science

interactive explainer

SHOW HN2018

111points
27comments
#392of 2,155 in 2018
Top 19%of 2018 by points

How HN took it

QuietFewer than 5 comments about the project

1 positive, 0 neutral or asking, 0 mixed, 0 critical, out of 1 comments about the project.

Docs: 1 for, 0 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Helpful for understanding Python internals and list implementation

    From 2 comments
    • So... Because lists are dynamically typed and heterogeneous, does that mean the underlying C is basically a contiguous segment of memory of python object references? Then in…
      Waterluvian on HN
    • I keep forgetting just how readable cpython source is. I'm still mentally stuck in my beginner years, where it was all Greek to me. Thanks for sharing these links.
      Waterluvian on HN

Objections

  • Calling Python lists arrays is misleading; they hold pointers to objects

    From 3 comments
    • Strictly speaking, lists are not arrays. I'm not aware of what the specification for a list would be, this is the closest I'm aware of:…
      joatmon-snoo on HN
    • No, they are not. At "best" they are implemented "like" an array of pointers to the objects (scattered somewhere else in the memory) in the list. If you want an array (in the…
      _ZeD_ on HN
    • It's not implemented like that and couldn't be. They aren't arrays unless you consider them arrays of pointers but this isn't a useful definition in Python. An array contains a…
      black-tea on HN

Requests

  • Clarify the wording about lists being arrays and check implementation differences across Python implementations

    From 2 comments
    • Python lists are actually arrays — contiguous chunks of memory. Just wondering here, is this guaranteed to always be the case? Practically it probably is, but does the Python…
      stinos on HN
    • It is indexable, and it is used as an array, so I guess it is an array in all implementations. But good point, I should check this. Dicts are definktely implemented differently…
      eatitraw on HN

Questions

  • Is a Python list an array, and is its contiguous layout guaranteed by the language spec or only CPython?

    From 3 comments
    • Python lists are actually arrays — contiguous chunks of memory. Just wondering here, is this guaranteed to always be the case? Practically it probably is, but does the Python…
      stinos on HN
    • Python doesn't really have a spec in the way that, say, C# does. The docs are missing things like whether the argument is positional-only, exact exceptions raised in all cases,…
      lozenge on HN
    • According to this post: https://news.ycombinator.com/item?id=18707403, "Lists aren't called arrays in Python because they're not arrays. Next!". I really am confused now. Is it…
      johnisgood on HN

Alternatives named

  • Python array.array module

    From 1 comment
    • If you want some closer to C arrays, you can use Python array.array, which is part of the standard library. https://docs.python.org/3/library/array.html…
      dorfsmay on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/18754010)