Everything You Need To Know About Peregrine, A New Programming Language

Peregrine is a Python-like programming language that is as fast as C.

Peregrine is a new programming language with a syntax similar to Python but execution speed comparable to C (currently under development). Recently, Ethan, one of the eight developers, shared some recent updates to Peregrine. 

While describing the Peregrine programming language, Ethan stated, “If you’re familiar with Python, you’re probably aware that it’s both simple to use and slow – which is a little inconvenient. To address this, my friends and I are developing a new programming language called Peregrine, which has a very similar syntax. Peregrine is compiled to C, allowing it to operate at the same speed as C.” Moreover, it was created by the developers as a quick alternative to Python and a simple alternative to C.


The basic objectives of the Peregrine language are as follows:

Subscribe to our Newsletter

Join our editors every weekday evening as they steer you through the most significant news of the day, introduce you to fresh perspectives, and provide unexpected moments of joy
Your newsletter subscriptions are subject to AIM Privacy Policy and Terms and Conditions.
  • Simple to use 
  • Quick
  • Highly modular 
  • Takes up less memory
  • Faster compilation

These are a few of Peregrine’s most recent enhancements:

Type Inference

Peregrine’s Type Inference function is one of the company’s newest additions, making it possible to write Peregrine code straightforwardly. Type inference is the process of determining the type of an expression in a formal language automatically. This category includes programming languages and mathematical type systems, as well as natural languages in certain disciplines of computer science and linguistics.


Despite the fact that this appears to be a typical feature in any programming language, it takes time to implement these. There isn’t much to say about it because it appears in every programming language.


Peregrine now has a new feature called Ccode, which is now ready for use. Peregrine supports the execution of C code through the use of Ccode. Here’s an illustration:

Source: Peregrine programming

The variables specified outside the Ccode block can be utilised inside the Ccode block, and vice versa, as seen in the example above. This also implies that any C library can be imported and used in Peregrine through the use of Ccode.

Inline Assembly

Peregrine incorporates inline assembly. In programming, some compilers include an inline assembler as a feature that enables the inclusion of low-level assembly code within a programme alongside code built from a higher-level language such as C or Ada.

Here is an illustration:

Source: Peregrine programming

As expected, this program prints 95. In a similar vein, there are several other examples in the Peregrine test directory


The author asserts that Peregrine is as fast as C, providing several benchmarks to support this assertion.

Source: Peregrine programming

According to the author, here, the Fibonacci series from 0 to 40 was calculated recursively using Python on the left side, which took 32 seconds. On the other hand, Peregrine on the right side took only 1 second, making it 32 times faster. Furthermore, it is evident that its syntax is extremely similar to that of the Python programming language. As a point of reference, here is a benchmark with C.

Source: Peregrine programming

According to the above result, Peregrine is as quick (if not faster) than C (both took 1 sec)

Why is C so fast?

Modern programming languages include garbage collection, dynamic typing, and other features that make designing programmes easier. The catch is that this adds additional processing overhead, which degrades the application’s performance. C lacks all of that, which means there is no overhead, but the programmer must be able to allocate and free memory to avoid memory leaks and cope with static types of variables. Hence C is faster than other modern languages.


In response to a comment in DEV Community, “Python could improve the example of Fibonacci by resolving the performance issue with @lru cache for the memorising, which would improve the performance of the code. In this case, it is a problem of memory consumption. It would be fantastic to demonstrate the performance and memory consumption comparison between Python and Peregrine for this example to demonstrate how effective the Peregrine language is in this situation. Otherwise, I have my doubts that Peregrine is consuming more memory.” 

Source: Peregrine programming

Saptak Bhowmik, a contributor of the Peregrine language, responded as follows: “Using @lru cache, on the other hand, is a form of cheating. Compared with a multithreaded Python application against a single-threaded C programme, Python is quite likely to win”.

Planned Features 

The following are the features that will be included in the upcoming release.

  • Structs 
  • Additional decorators for a variety of purposes
  • Peregrine’s Python ecosystem – Peregrine supports the Python module.

Peregrine is scheduled to release version 0.0.1 in March this year, according to the contributors.
For more information: Repo: Github.

Dr. Nivash Jeevanandam
Nivash holds a doctorate in information technology and has been a research associate at a university and a development engineer in the IT industry. Data science and machine learning excite him.

Download our Mobile App

MachineHack | AI Hackathons, Coding & Learning

Host Hackathons & Recruit Great Data Talent!

AIMResearch Pioneering advanced AI market research

With a decade of experience under our belt, we are transforming how businesses use AI & data-driven insights to succeed.

The Gold Standard for Recognizing Excellence in Data Science and Tech Workplaces

With Best Firm Certification, you can effortlessly delve into the minds of your employees, unveil invaluable perspectives, and gain distinguished acclaim for fostering an exceptional company culture.

AIM Leaders Council

World’s Biggest Community Exclusively For Senior Executives In Data Science And Analytics.

3 Ways to Join our Community

Telegram group

Discover special offers, top stories, upcoming events, and more.

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Subscribe to our Daily newsletter

Get our daily awesome stories & videos in your inbox