{"id":53496,"date":"2020-07-24T09:00:00","date_gmt":"2020-07-24T13:00:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=53496"},"modified":"2022-11-21T09:45:56","modified_gmt":"2022-11-21T14:45:56","slug":"python-performance-a-comparison","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/","title":{"rendered":"Python Performance: A Comparison"},"content":{"rendered":"\n<p><em>This article was first posted on <a href=\"https:\/\/quantdare.com\/python-performance-a-comparison\/\">QuantDare Blog<\/a>.<\/em><\/p>\n\n\n\n<p>When coding in any computer language, performance is always an important feature to take into consideration. But if it comes to Python, this factor becomes crucial. In this post, we will see how the way we develop a function and whether we\u2019re using a library or not can make dramatical changes regarding performance.<\/p>\n\n\n\n<p>Let\u2019s look at&nbsp;<strong>two possible implementations of a simple function<\/strong>, which apply different transformations according to the input values:<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\ndef some_calcs1(x):<br><br>\n     \n    if x &gt; 0.04:<br>\n         return 0.4<br>\n    elif x &gt; 0.01:<br>\n         return 10 * x<br>\n    elif x &gt; 0:<br>\n         return 10 * x \/ 3.0 + 1 \/ 15.0<br>\n    else:<br>\n         return 0\n<\/p>\n\n\n\n<p>This second function would obtain the same result as the previous one:<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\ndef some_calcs2(x):<br><br>\n  \n    return (x > 0.04) * 0.4 + \\<br>\n           ((x > 0.01) &#038; (x <= 0.04)) * x * 10.0 + \\ ((x > 0) &#038; (x <= 0.01)) * (x * 10.0 \/ 3.0 + 1.0 \/ 15.0) + \\<br>\n           0.0\n<\/p>\n\n\n\n<p>Let\u2019s define 3 equivalent variables in different types: a list of lists, a Numpy array and a DataFrame from Pandas:<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\nimport pandas as pd<br>\nimport numpy as np<br><br>\n \nxarray = np.random.rand(1000,10)<br>\nxlist = xarray.tolist<br>\nxdf = pd.DataFrame(xarray)<br>\n<\/p>\n\n\n\n<p><strong>Lists&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/strong><\/p>\n\n\n\n<p>If you&nbsp;<strong>apply the two functions defined above to a list of lists<\/strong>, the first function is 5 times faster than the second, just as a consequence of the way they are coded. In function 1 only the code inside the fulfilled condition is executed, while in function 2 all the calculations are done for every figure.<\/p>\n\n\n\n<p><p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n%timeit z1 = [list(map(some_calcs1, z)) for z in xlist]<br>\n%timeit z2 = [list(map(some_calcs2, z)) for z in xlist]\n<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/quantdare.com\/wp-content\/uploads\/sites\/2\/2018\/04\/listfun_detail.png\" alt=\"\" class=\"wp-image-7295 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p><strong>Numpy arrays<\/strong><\/p>\n\n\n\n<p>But, what if we worked with Numpy arrays instead of lists? Can we expect the same behaviour?<\/p>\n\n\n\n<p>First of all, in order to \u201cmap\u201d the first function in Numpy we would need to&nbsp;<a href=\"https:\/\/docs.scipy.org\/doc\/numpy\/reference\/generated\/numpy.vectorize.html\" target=\"_blank\" rel=\"noreferrer noopener\">vectorize<\/a>&nbsp;it (we will use a decorator), otherwise it would not work. Vectorize a function allows us to apply the function to the whole array, instead of using a loop.<\/p>\n\n\n\n<p><p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\nimport numpy as np<br><br>\n \n@np.vectorize<br>\ndef some_calcs1_vec(x):<br>\n    if x &gt; 0.04:<br>\n        return 0.4<br>\n    elif x &gt; 0.01:<br>\n        return 10 * x<br>\n    elif x &gt; 0:<br>\n        return 10 * x \/ 3.0 + 1 \/ 15.0<br>\n    else:<br>\n        return 0\n<\/p><\/p>\n\n\n\n<p>At first sight, we realise that the performance has improved a little with the first function, and tremendously with the second one. But what amazes the most is that now&nbsp;<strong>the second function is much faster than the first one!<\/strong>&nbsp;But, were not we saying that the first implementation was faster? Let\u2019s explain what is going on here:<\/p>\n\n\n\n<p><p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n%timeit z1 = some_calcs1_vec(xarray)<br>\n%timeit z2 = some_calcs2(xarray)\n\n<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/quantdare.com\/wp-content\/uploads\/sites\/2\/2018\/04\/numpyfun_detail.png\" alt=\"\" class=\"wp-image-7296 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Numpy has what they call the universal functions (<a href=\"https:\/\/docs.scipy.org\/doc\/numpy-1.14.0\/reference\/ufuncs.html\" target=\"_blank\" rel=\"noreferrer noopener\">ufunc<\/a>), which are functions that can receive array like inputs and return array output, but they operate over each element. It is quite the same that we do when vectorizing, but with faster results, since these functions look over the elements by loops in a lower level (C implementations). Besides, these functions broadcast (adjust) the input arrays when they have different dimensions.<\/p>\n\n\n\n<p>Then, the first function is \u201cgeneralized\u201d to operate like the ufuncs, but the second function does use the ufuncs.<\/p>\n\n\n\n<p>Alright, but I don\u2019t see any ufunc at all! Well, the different operators you see in the formulas, like *, +, &amp;, &gt; are overloaded with the ufuncs multiply(), add(), logical_and() or greater(). Then, for example, x+4.0 would be the same as applying np.add(x, 4.0).<\/p>\n\n\n\n<p><strong>Pandas DataFrame<\/strong><\/p>\n\n\n\n<p>To conclude, we might wonder if Pandas library would obtain similar performance as Numpy, taking into account that Pandas makes use of Numpy arrays underneath.<\/p>\n\n\n\n<p>If we apply a map operation with the functions defined, the performance would be slower than&nbsp;the one obtained by mapping a list and, obviously, much slower than Numpy:<\/p>\n\n\n\n<p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n%timeit z1 = xdf.applymap(some_calcs1)<br>\n%timeit z2 = xdf.applymap(some_calcs2)\n\nIf we apply the functions directly over Pandas DataFrames, the first vectorized function performs slower than with a Numpy array; the second function loses all its potential when applying over a DataFrame, with a performance similar to the one obtained with a list.\n\n\n\n<p><p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n%timeit z1 = some_calcs1_vec(xdf)<br>\n%timeit z2 = some_calcs2(xdf)\n\n<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/quantdare.com\/wp-content\/uploads\/sites\/2\/2018\/04\/pandasvec_detail.png\" alt=\"\" class=\"wp-image-7299 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>Finally, to complicate matters even further, we could use the \u201capply \u201d DataFrame method which applies the function specified to entire rows or columns; as we see below, the choice of the axis to operate on is a factor that makes a big difference in terms of performance.<\/p>\n\n\n\n<p>In general, it is advisable not to use this kind of mapping in Pandas if you want an acceptable performance.<\/p>\n\n\n\n<p><p style=\"background-color:#fcfcdb;font-size:11px\" class=\"has-background\">\n%timeit z1 = xdf.apply(some_calcs1_vec, axis=0)<br>\n%timeit z2 = xdf.apply(some_calcs1_vec, axis=1)\n\n<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" data-src=\"https:\/\/quantdare.com\/wp-content\/uploads\/sites\/2\/2018\/04\/pandasapply_detail.png\" alt=\"\" class=\"wp-image-7298 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>So, be warned: the way you implement your code and the choice of the right libraries and functions can make your programs fly or be as slow as molasses in January.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Join QuantDare for a tutorial on Numpy, Pandas DataFrames and coding Python functions in order to improve algo performance.<\/p>\n","protected":false},"author":460,"featured_media":33705,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,349,338,341,351,344],"tags":[851,4922,1225,1224,595,494],"contributors-categories":[13705],"class_list":{"0":"post-53496","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science","8":"category-programing-languages","9":"category-python-development","10":"category-ibkr-quant-news","11":"category-quant-development","12":"category-quant-europe","13":"category-quant-regions","14":"tag-algo-trading","15":"tag-econometrics","16":"tag-numpy","17":"tag-pandas","18":"tag-python","19":"tag-quant","20":"contributors-categories-quantdare"},"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Performance: A Comparison | IBKR Quant<\/title>\n<meta name=\"description\" content=\"Join QuantDare for a tutorial on Numpy, Pandas DataFrames and coding Python functions in order to improve algo performance.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/53496\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Performance: A Comparison | via IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"Join QuantDare for a tutorial on Numpy, Pandas DataFrames and coding Python functions in order to improve algo performance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-24T13:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-21T14:45:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/01\/python-circuits-hand.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"J. Gonz\u00e1lez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"J. Gonz\u00e1lez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"J. Gonz\u00e1lez\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/d5ce51cd5aefe2c12cdbcb6260af2c8b\"\n\t            },\n\t            \"headline\": \"Python Performance: A Comparison\",\n\t            \"datePublished\": \"2020-07-24T13:00:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:45:56+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/\"\n\t            },\n\t            \"wordCount\": 128,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/01\\\/python-circuits-hand.jpg\",\n\t            \"keywords\": [\n\t                \"Algo Trading\",\n\t                \"Econometrics\",\n\t                \"NumPy\",\n\t                \"Pandas\",\n\t                \"Python\",\n\t                \"Quant\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Development\",\n\t                \"Quant Europe\",\n\t                \"Quant Regions\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/\",\n\t            \"name\": \"Python Performance: A Comparison | via IBKR Quant Blog\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/01\\\/python-circuits-hand.jpg\",\n\t            \"datePublished\": \"2020-07-24T13:00:00+00:00\",\n\t            \"dateModified\": \"2022-11-21T14:45:56+00:00\",\n\t            \"description\": \"Join QuantDare for a tutorial on Numpy, Pandas DataFrames and coding Python functions in order to improve algo performance.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/python-performance-a-comparison\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/01\\\/python-circuits-hand.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/01\\\/python-circuits-hand.jpg\",\n\t            \"width\": 900,\n\t            \"height\": 540,\n\t            \"caption\": \"Python\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/d5ce51cd5aefe2c12cdbcb6260af2c8b\",\n\t            \"name\": \"J. Gonz\u00e1lez\",\n\t            \"description\": \"QuantDare Blog https:\\\/\\\/quantdare.com\\\/author\\\/jgonzalezomega\\\/\",\n\t            \"sameAs\": [\n\t                \"https:\\\/\\\/quantdare.com\\\/author\\\/jgonzalezomega\\\/\"\n\t            ],\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/jgonzalez\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Performance: A Comparison | IBKR Quant","description":"Join QuantDare for a tutorial on Numpy, Pandas DataFrames and coding Python functions in order to improve algo performance.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/53496\/","og_locale":"en_US","og_type":"article","og_title":"Python Performance: A Comparison | via IBKR Quant Blog","og_description":"Join QuantDare for a tutorial on Numpy, Pandas DataFrames and coding Python functions in order to improve algo performance.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/","og_site_name":"IBKR Campus US","article_published_time":"2020-07-24T13:00:00+00:00","article_modified_time":"2022-11-21T14:45:56+00:00","og_image":[{"width":900,"height":540,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/01\/python-circuits-hand.jpg","type":"image\/jpeg"}],"author":"J. Gonz\u00e1lez","twitter_card":"summary_large_image","twitter_misc":{"Written by":"J. Gonz\u00e1lez","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/"},"author":{"name":"J. Gonz\u00e1lez","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/d5ce51cd5aefe2c12cdbcb6260af2c8b"},"headline":"Python Performance: A Comparison","datePublished":"2020-07-24T13:00:00+00:00","dateModified":"2022-11-21T14:45:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/"},"wordCount":128,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/01\/python-circuits-hand.jpg","keywords":["Algo Trading","Econometrics","NumPy","Pandas","Python","Quant"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development","Quant Europe","Quant Regions"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/","name":"Python Performance: A Comparison | via IBKR Quant Blog","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/01\/python-circuits-hand.jpg","datePublished":"2020-07-24T13:00:00+00:00","dateModified":"2022-11-21T14:45:56+00:00","description":"Join QuantDare for a tutorial on Numpy, Pandas DataFrames and coding Python functions in order to improve algo performance.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/python-performance-a-comparison\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/01\/python-circuits-hand.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/01\/python-circuits-hand.jpg","width":900,"height":540,"caption":"Python"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/d5ce51cd5aefe2c12cdbcb6260af2c8b","name":"J. Gonz\u00e1lez","description":"QuantDare Blog https:\/\/quantdare.com\/author\/jgonzalezomega\/","sameAs":["https:\/\/quantdare.com\/author\/jgonzalezomega\/"],"url":"https:\/\/www.interactivebrokers.com\/campus\/author\/jgonzalez\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/01\/python-circuits-hand.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/53496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/460"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=53496"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/53496\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/33705"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=53496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=53496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=53496"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=53496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}