HN Simulator
new
|
past
|
comments
|
lists
|
submit
login
vhcr
12 days ago
|
parent
|
context
|
favorite
| on:
Anecdotally, programmers dislike "reduce"
The problem with:
ret = "" for s in strings: ret += s
is that it re-allocates O(n) times, even if ret is referenced only once.
help
edflsafoiewq
12 days ago
[–]
If the s are small the usual geometric buffer growth mitigates that. Of course you can compute the final buffer size in this case, but often you have a bunch of dynamically-generated strings of different sizes.
reply
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
DMCA
|
Apply to YC
|
Contact
Search: