Message108587
| Author |
andybuckley |
| Recipients |
andybuckley |
| Date |
2010年06月25日.12:00:44 |
| SpamBayes Score |
0.0007047675 |
| Marked as misclassified |
No |
| Message-id |
<1277467249.03.0.329544397504.issue9080@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I know that Python lists aren't designed for efficient prepending, but sometimes when working with small lists it's exactly what needs to be done (search path lists being a common example). For a programmer aware of the performance issue and having convinced themself that it's not a problem for their use-case, it's a niggle that there is no prepend() function for lists by direct analogy to the commonly-used append().
Writing l = ["foo"] + l, or something mucky based on l.insert(0, ...) or reverse/append/reverse is annoyingly asymmetric and no more performant. So I suggest that l.append(x) be added to the list interface, with a prominent warning in the documentation that it's not an efficient operation on that type (possibly mention the complexity scaling with list length). I think the role of the interface is to make simple things simple, not to make it difficult to do simple-but-inefficient things that people will do anyway ;) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年06月25日 12:00:49 | andybuckley | set | recipients:
+ andybuckley |
| 2010年06月25日 12:00:49 | andybuckley | set | messageid: <1277467249.03.0.329544397504.issue9080@psf.upfronthosting.co.za> |
| 2010年06月25日 12:00:46 | andybuckley | link | issue9080 messages |
| 2010年06月25日 12:00:44 | andybuckley | create |
|