2 ms·
I think you misunderstand. Here's an example: ``` foos = [Foo(a=0), Foo(a=1)] f0 = foos[0] foos[0] = Foo(a=2) print(f0.a) # 0 print(foos[0].a) # 2 ``` `
by weberc2 10y ago
I think you misunderstand. Here's an example:
```
foos = [Foo(a=0), Foo(a=1)]
f0 = foos[0]
foos[0] = Foo(a=2)
print(f0.a) # 0
print(foos[0].a) # 2
```
`foos` is a list of type `Foo`, but it still can't be safely made into a dense list (at least not naively).
- sanxiyn 10y agoYou are right. Array elements need to have value semantics to do complete unboxing. But for NumPy-like use cases, they do. It should be noted that PyPy already does unboxing Animats suggested, without any type annotation. At least for 4 years. It is not theoretical. https://morepypy.blogspot.com/2011/10/more-compact-lists-with-list-strategies.html https://morepypy.blogspot.com/2011/10/more-compact-lists-wit...