Re: [swift-users] Performance critical code in Swift

2016-10-02 Thread David Hart via swift-users
That fact that Realm has an ORM layer, and that batch inserts are noticeably slower than in SQLite makes it less performant in certain scenarios. The fact that is does not support JOIN queries also causes issues in other performance scenarios. > On 2 Oct 2016, at 20:26, Marco S Hyman via swift-

Re: [swift-users] A sample Rational number type

2016-10-02 Thread Hooman Mehr via swift-users
> On Oct 2, 2016, at 5:23 PM, Dave Abrahams via swift-users > wrote: > Presumably you mean: > > let r2 = r±0.0005 // turn a Rational into a Double with no more than >// .0005 rounding error > > ? That is supercute! > It is actually the other way around: It returns a rati

[swift-users] clang builtins from Swift?

2016-10-02 Thread Jean-Denis Muys via swift-users
Hi, Xcode seems to think that [some] builtins can be used from Swift. It autocompletes popcount for example, and command-clicking the function opens a bona fide interface file, with the following declaration (among others): public func __builtin_popcount(_: UInt32) -> Int32 However, when I try t

Re: [swift-users] UnsafeMutablePointer on the stack?

2016-10-02 Thread Dave Abrahams via swift-users
on Sun Oct 02 2016, Mike Ferenduros wrote: > You can use a local like this: > var x: UInt32 = 0 > withUnsafePointer(to: x) { randomWordPT in > //your existing code here > } > > Or I'm not sure if small arrays go on the heap, but They do. > var bytes: [UInt8] = [0,0,0,0]

Re: [swift-users] A sample Rational number type

2016-10-02 Thread Dave Abrahams via swift-users
on Fri Sep 30 2016, Hooman Mehr wrote: > For anybody who is interested: This gist > > contains a Rational number implementation for Swift 3.0. It is a > single file that you can paste in a playground and take a look, or > remove t

Re: [swift-users] UnsafeMutablePointer on the stack?

2016-10-02 Thread Mike Ferenduros via swift-users
You can use a local like this: var x: UInt32 = 0 withUnsafePointer(to: x) { randomWordPT in //your existing code here } Or I'm not sure if small arrays go on the heap, but var bytes: [UInt8] = [0,0,0,0] _ = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)

Re: [swift-users] UnsafeMutablePointer on the stack?

2016-10-02 Thread Dave Abrahams via swift-users
on Sun Oct 02 2016, Jean-Denis Muys wrote: > Hi, > > I have some issues using the new raw memory API. For instance, let's > suppose I want to call the `SecRandomCopyBytes` API to generate a > cryptographically secure random 32-bit number. The difficulty is its 3rd > argument, which is declared a

[swift-users] UnsafeMutablePointer on the stack?

2016-10-02 Thread Jean-Denis Muys via swift-users
Hi, I have some issues using the new raw memory API. For instance, let's suppose I want to call the `SecRandomCopyBytes` API to generate a cryptographically secure random 32-bit number. The difficulty is its 3rd argument, which is declared as UnsafeMutablePointer. Here is a function that does that

Re: [swift-users] Swift Package Manager (SPM) Deployment Target

2016-10-02 Thread Gmail via swift-users
And here’s the command I’ve been using to generate the Xcode project for anyone else interested: $ swift package generate-xcodeproj --verbose --xcconfig-overrides ./Configuration.xcconfig --output ./SPMTester.xcodeproj And the xcconfig: SDKROOT = macosx MACOSX_DEPLOYMENT_TARGET = 10.11 Cheers

Re: [swift-users] Swift Package Manager (SPM) Deployment Target

2016-10-02 Thread Gmail via swift-users
Thanks for all the help so far everyone. I’ve now been able to successfully compile an example command line tool with Alamofire using `--xcconfig-overrides` flag and an .xcconfig file. However, I’ve run into one issue and have an additional question. The issue I’m hitting is that the project st

Re: [swift-users] CharacterSet vs Set

2016-10-02 Thread Dave Abrahams via swift-users
on Sun Oct 02 2016, Jean-Denis Muys wrote: > I was playing with CharacterSet, and I came up with: > > let vowels = CharacterSet(charactersIn: "AEIOU") Yeah, because CharacterSet is a set of UnicodeScalars, not a set of Character. That should probably get fixed somehow. I suggest filing a rada

Re: [swift-users] Performance critical code in Swift

2016-10-02 Thread Marco S Hyman via swift-users
> > On a broader note, I have yet to see a true modern replacement for SQLite on > the embedded side. There are any number of lightweight document stores, but > they either have performance worse than SQLite, or are not really suitable > for embedded use. Realm ??? It’s faster than sqlite and

[swift-users] CharacterSet vs Set

2016-10-02 Thread Jean-Denis Muys via swift-users
I was playing with CharacterSet, and I came up with: let vowels = CharacterSet(charactersIn: "AEIOU") let char: Character = "E" vowels.contains(char) That last line doesn't compile: I get "*cannot convert value of type 'Character' to expected argument type 'UnicodeScalar'*" The problem is, I

Re: [swift-users] Performance critical code in Swift

2016-10-02 Thread Maury Markowitz via swift-users
> On Oct 1, 2016, at 4:50 PM, Игорь Никитин via swift-users > wrote: > > For such of tasks C (or maybe C++) is a good choice. But how can Swift do > this as fast as C? > Of course I need to use low level C I/O api, but there are another things > that I need to know? All things considered, the