« first day (2345 days earlier)      last day (877 days later) » 

2:46 AM
@LuisMendo Very clever. I’m not sure I’d be able to fool myself that way, but I’ll try.
 
 
5 hours later…
7:22 AM
@LuisMendo someone had to save the poor chap from utter disaster
 
 
8 hours later…
3:18 PM
Wow! It looks like in 2020a or soon before they optimized the x = [x,1] growing pattern! stackoverflow.com/q/70185900/7328782
 
@CrisLuengo I think we disucssed this once, but "growing" your array every e.g. 1e4 iterations with another 1e4 elements is even faster, if the number of elements is large enough
 
@Adriaan yes! I Remember now that you worked out some code for that.
 
 
2 hours later…
5:29 PM
so x = [x, 1] is as fast as x(end+1) = 1?
 
 
2 hours later…
7:20 PM
9
Q: MATLAB adding array elements iteratively: time behavior

Peter Barrett BryanSo I know this isn't the recommended technique (preallocating is better), but I got really curious about this timing behavior; I'm curious what might be happening under the hood. In my head, adding an element to an array could induce a couple different reasonable behaviors in memory depending on...

But this may change with each version...
 
 
2 hours later…
9:15 PM
@LuisMendo Thanks for fixing that typo. That's a weird thing my phone does, if I don't pay attention, I get the wrong type of quotes. :(
 
9:49 PM
@LuisMendo ah I see, one of these things, thanks for the link!
 
@CrisLuengo Yes, it also happens to me. iPhone?
 
 
1 hour later…
11:04 PM
@LuisMendo Indeed, iPhone. You're not supposed to write code on your phone, I guess... :)
@flawr I don't know if they're as fast, but x=[x,1] is much faster, apparently, in R2020a than it was in R2018b. I can see the JIT having been instructed to produce the same code for x=[x,1] as it produces for x(end+1)=1.
 
oh nice!
didn't even know you could do that:)
 
Yeah, you can assign to any index, even if it's out of bounds. And end works in more ways than people realize, it's very useful. x(floor(end/2)+1). Stuff like that.
 
no I mean looking at the JIT stuff!
I do love the end (and really miss it in python)
 
Oh, with "I can see" I meant "I can imagine". I can't really see what the JIT does.
 
ah oh:)
now I understand what you meant:)
 
11:15 PM
With MATLAB it's all guesses :)
 
haha
yeah
 
@CrisLuengo I remember code golfing in my previous, Android phone with no problem :-D
 
11:32 PM
@LuisMendo If only Android phones were usable... My wife has one, I can't make heads or tails from it. I feel illiterate when trying to use that phone.
 
11:52 PM
@CrisLuengo your iphone must be terribly usable if you can't disable autocorrect :P
 
@AndrasDeak Oh, but most of the time I need autocorrect. I make so many typos on that fucking little screen...
The thing I hate the most about autocorrect is that it will turn "were" into "we're", making me look like an idiot that doesn't know English grammar.
Other than that, it saves me from having to type correctly. I can just point in the general direction to the right letters, and it gets the word right almost every time.
 

« first day (2345 days earlier)      last day (877 days later) »