element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Blog Codor Python Compiler Promises to Achieve C/C++ Performance And Speeds
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Catwell
  • Date Created: 12 Apr 2023 7:06 PM Date Created
  • Views 1236 views
  • Likes 8 likes
  • Comments 0 comments
  • python
  • statistics
  • cabeatwell
  • engineering_life
  • code
  • innovation
Related
Recommended

Codor Python Compiler Promises to Achieve C/C++ Performance And Speeds

Catwell
Catwell
12 Apr 2023

image

Codon, a Python-based compiler, allows Python scripts to achieve similar performance levels as the C/C++ programming language. (Image Credit: Cg_prodigy/pixabay)

At some point, new or experienced computer programmers have learned Python and realized that it's quite bulky in terms of memory usage and processing power versus C or C++. Researchers at MIT's Computer Science and Artificial Intelligence Laboratory (CSAIL) developed Codon, a compiler designed to efficiently run Python code — similar to the C++ programming languages. 

"Typical speedups over Python are on the order of 10-100x or more on a single thread. Codon's performance is typically on par with (and sometimes better than) that of C/C++. Unlike Python, Codon supports native multithreading, which can lead to speedups many times higher still," according to the repository,

However, apart from its delayed open-source license, Condon doesn't have all the Python language modules integrated into it. Some features, including dynamic type manipulation and runtime reflection, are also excluded. These make code analysis and optimization more challenging. Instead, Codon uses a statically-typing compiler engine, which combines with an optimizable and flexible intermediate representation (IR) for quicker code generation. 

image

The table compares Python (CPython 3), PyPy, Codon, and C++ from numerous benchmarks on Python's pyperformance benchmark suite. The y-axis represents the speed-up over the CPython implementation. (Image Credit: MIT)

MIT originally built Codon as a framework to develop high-performance Python DSLs, a language designed for a specific purpose rather than a general-purpose programming language. Now, Condon expanded into a Python 3-compatible language compiler. Codon "enables the development of DSLs that share Python's syntax and semantics together with added domain-specific features and IR optimizations."

The authors said Python scripts run similarly to C since Codon outputs native machine code without Python runtime overhead. "Unlike other performance-oriented Python implementations (such as PyPy or Numba), Codon is built from the ground up as a standalone system that compiles ahead-of-time to a static executable and is not tied to an existing Python runtime (e.g., CPython or RPython) for execution," according to the paper. "As a result, Codon can achieve better performance and overcome runtime-specific issues such as the global interpreter lock."

The team also suggests that Codor-based DSLs could have applications for data compression, parallel programming, and bioinformatics. In addition, Condor can even boost traditional Python applications. However, those using external libraries like Django or DocUtils must use a CPython bridge, decreasing performance. In fact, a developer says a Fibonacci script ran 70 times faster compared to the CPython version. 

"Python is the language of choice for domain experts that are not programming experts. If they write a program that gets popular, and many people start using it and run larger and larger datasets, then the lack of performance of Python becomes a critical barrier to success," says Saman Amarasinghe, MIT professor of electrical engineering and computer science and CSAIL principal investigator. "Instead of needing to rewrite the program using a C-implemented library like NumPy or totally rewrite in a language like C, Codon can use the same Python implementation and give the same performance you'll get by rewriting in C. Thus, I believe Codon is the easiest path forward for successful Python applications that have hit a limit due to lack of performance."

So far, Condor is already being used in various fields, including deep learning, and can be used for app development and testing. The developers plan on implementing additional Python features in Condor within the next few months. 

Have a story tip? Message me at: http://twitter.com/Cabe_Atwell

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube