Aren’t NSNumbers now created as tagged pointers when possible? That doesn’t cover 100% of the difference between C arrays and NSArray, but it would be a huge portion of it.
Jeff Kelley [email protected] | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org On Mon, Mar 2, 2015 at 12:29 PM, Jens Alfke <[email protected]> wrote: > > On Mar 1, 2015, at 10:49 PM, Patrick J. Collins < > [email protected]> wrote: > > Would you argue that I should in fact be using C arrays since they are > light-weight, fast, etc… ? > > > Yes. I know that “premature optimization is the root of all evil”, but the > performance gap between a C array of floats and an NSArray of NSNumbers is > _vast_. Orders of magnitude, I’m sure. Each NSNumber has to be malloc’ed, > accessing one requires a method dispatch, and you’ve lost any ability to > have the compiler vectorize the math. > > If you don’t want to call malloc/realloc/free yourself, consider using > Obj-C++ for this source file and using a std::vector<float>. > > (Even Python, which is higher-level than Obj-C, has a popular module > called NumPy that stores arrays of numbers in native form and implements > fast vector operations on them.) > > —Jens > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Objc-language mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > > https://lists.apple.com/mailman/options/objc-language/slaunchaman%40gmail.com > > This email sent to [email protected] >
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com This email sent to [email protected]
