Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31673 > unrolled thread
| Started by | Demian Brecht <demianbrecht@gmail.com> |
|---|---|
| First post | 2012-10-18 11:42 -0700 |
| Last post | 2012-10-18 11:42 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: len() on mutables vs. immutables Demian Brecht <demianbrecht@gmail.com> - 2012-10-18 11:42 -0700
| From | Demian Brecht <demianbrecht@gmail.com> |
|---|---|
| Date | 2012-10-18 11:42 -0700 |
| Subject | Re: len() on mutables vs. immutables |
| Message-ID | <mailman.2462.1350585776.27098.python-list@python.org> |
On 10/18/2012 11:29 AM, Terry Reedy wrote:> Or the length could be the difference of two pointers -- address of the > first empty slot minus address of first item. That would assume contiguous blocks of memory, which I would find to be rather dangerous (of an assumption that is) in most dynamic cases (obviously totally depends on implementation details). > str, bytes, bytearrays, arrays, sets, frozensets, dicts, dictviews, and > ranges should all return len in O(1) time. That includes the possibility > of a subtraction as indicated above. Awesome. Pretty much what I figured. Of course, I'll have to dig around the source just to confirm this with my own eyes (more just curiosity than anything), so if you know whereabouts to look, it would be most helpful :)
Back to top | Article view | comp.lang.python
csiph-web