0% found this document useful (0 votes)
59 views1 page

Swift Vs Python: The Final Round: SYN TAX

Swift and Python have some minor syntactic differences in areas like conditional statements, loops, and type inference. However, the document's performance tests found Swift to be significantly faster than Python for sorting a large list and multiplying matrices. Specifically, Swift was 1.4x faster for sorting and 4x faster for matrix multiplication. While Apple claims Swift can be 100x faster than Python, this document did not replicate that level of performance difference. Overall, the document concludes Swift outperformed Python in the given performance tests based on code with similar time complexities.

Uploaded by

Andrea Padula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views1 page

Swift Vs Python: The Final Round: SYN TAX

Swift and Python have some minor syntactic differences in areas like conditional statements, loops, and type inference. However, the document's performance tests found Swift to be significantly faster than Python for sorting a large list and multiplying matrices. Specifically, Swift was 1.4x faster for sorting and 4x faster for matrix multiplication. While Apple claims Swift can be 100x faster than Python, this document did not replicate that level of performance difference. Overall, the document concludes Swift outperformed Python in the given performance tests based on code with similar time complexities.

Uploaded by

Andrea Padula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SWIFT VS PYTHON: THE FINAL ROUND

Andrea Padula

SYN TAX PERFORM ANCE

There are little small difference in python and swift :


- CONDITIONAL STATEM ENTS
The first performance that I analyze is sorting. Sort a list of 1,000,000 elements in ascending order. The
- DECLARING CONSTANTS AND VARIABLES
numbers were generated from a ranged of ?1000 to 1000. Quick sort was used for both languages.
Swift has rich support for type inference and constants. Python is dynamic and does
not natively support constants

- INTEGER BOUNDS
Python does not have upper bounds for integer numbers.While swift has 32 bit limit
like Java.
var b = Int32.max The second comparison was done by multiply two matrices 500 x 500

- TYPE INFERENCE
Swift is a strongly-typed language and uses type-inference, but you can declare a
variable with an explicit type. On the other hand Python is a dynamic language , so
there is no type system , but it is not evident in the syntax.

- LOOPS
In python there are only two type of loops. While loop and for loop. While
in Swift we have 4 type of loop:
-1 for-in
This loop is typical loop that loop thought each item in a range.

CON CLU SION

In my study Swift ended up to be the fastest in both cases: sorting and multiplication of a matrix.
In fact when Swift in sorting was 1.4 on average faster than Python. However in multiply
-2 for loop
matrices Swift out performed Python by a lot. In fact, Swift was 4 times faster than Python. The
- ARRAYS AND DICTIONARIES this is the same loop that we have in python code that I used for both languages was pretty much the same in time complexity. Therefore
Declaring an array and dictionary is almost identical in both languages.
-3 while loop based on my study we can definitely say that SWIFT was faster. Apple 's statement on Swift
this is like in pyhton. a group of statements that are going to be repeated presentation " Swift is faster than Python " is actually proven by my tests. However , I wasn't able
when the condition is true. otherwise it will stop to replicate the numbers of Swift's presentation where Apple claimed that Swift was on avrage
-4 do...while loop 100 times faster than Python. However, in Apple's presentation no reference is provided about
Like a while statement, except we know that the statement is going to be how they got those result , no mention of the machine or operating system or algorithm used to
executed at least once. time and to perform the benchmarks.

W ORKS CITED
"A Comparison of Programming Languages." A Comparison of Programming Languages. N.p., n.d. Web.

Qutheory. "Server Side Swift vs. The Other Guys - 1: Input." Medium. N.p., 05 June 2016.

Adrian Sutton. "From Java to Swift" Symphonious. N.p., n.d. Web.

Huy Nguye. "A Guide to Analyzing Python Performance Huy Nguyen." A Guide to Analyzing Python Performance Huy Nguyen.

You might also like