Is Swift really slow at dealing with numbers?
问题 As I was playing around with a swift tutorial, I started to write a custom isPrime method to check if a given Int is prime or not. After writing it I realized it was working properly but found it a bit slow to perform isPrime on some quite large numbers (still much lower then Int.max ). So I wrote the same piece of code in objc and the code was executed much faster (a factor of 66x). Here is the swift code: class Swift { class func isPrime(n:Int) -> Bool { let sqr : Int = Int(sqrt(Double(n)))