<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sanskar Jethi</title>
    <description>The latest articles on Forem by Sanskar Jethi (@sansyrox).</description>
    <link>https://forem.com/sansyrox</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F390317%2F0cb3c499-5569-43eb-a22b-ac500353d117.jpeg</url>
      <title>Forem: Sanskar Jethi</title>
      <link>https://forem.com/sansyrox</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sansyrox"/>
    <language>en</language>
    <item>
      <title>Hello, Robyn!</title>
      <dc:creator>Sanskar Jethi</dc:creator>
      <pubDate>Mon, 14 Feb 2022 21:58:38 +0000</pubDate>
      <link>https://forem.com/sansyrox/hello-robyn-39bm</link>
      <guid>https://forem.com/sansyrox/hello-robyn-39bm</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Hi, I'm Sanskar Jethi(&lt;a class="mentioned-user" href="https://dev.to/sansyrox"&gt;@sansyrox&lt;/a&gt;), the author and maintainer of Robyn!&lt;br&gt;
This article was written in celebration of Robyn passing 100k installs on PyPi.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is robyn?
&lt;/h2&gt;

&lt;p&gt;Robyn is a fast asynchronous web Python framework with a Rust runtime. Other similar products that are available are Flask, FastAPI, Django but they need a web server of choice. However, when you create a robyn app, you do not need an external web server for production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sansyrox/robyn" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgh-card.dev%2Frepos%2Fsansyrox%2Frobyn.svg" alt="sansyrox/robyn - GitHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 Why another web framework?
&lt;/h2&gt;

&lt;p&gt;Currently, all the other frameworks in the Python community are written only in Python, which does not allow true concurrency due to the notorious GIL and slow speed of execution. Robyn, having a Rust runtime and a coupled web server, tries to move around the GIL in many ways improving the runtime performance. While having a decoupled webserver brings along a lot of benefits, an integrated web server in Robyn allows us more control over the execution performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance Benchmarks(on a dual core machine)
&lt;/h3&gt;

&lt;p&gt;You can read the detailed version on the docs &lt;a href="https://sansyrox.github.io/robyn/#/comparison" rel="noopener noreferrer"&gt;website&lt;/a&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;*Flask(Gunicorn)&lt;/th&gt;
&lt;th&gt;FastAPI(API)&lt;/th&gt;
&lt;th&gt;Django(Gunicorn)&lt;/th&gt;
&lt;th&gt;Robyn(1 process and 1 worker)&lt;/th&gt;
&lt;th&gt;Robyn(5 processes and 5 workers)*&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Total: 5.5254 secs&lt;/td&gt;
&lt;td&gt;Slowest: 0.0784 secs&lt;/td&gt;
&lt;td&gt;Fastest: 0.0028 secs&lt;/td&gt;
&lt;td&gt;Average: 0.0275 secs&lt;/td&gt;
&lt;td&gt;Requests/sec: 1809.8082&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;total: 4.1314 secs&lt;/td&gt;
&lt;td&gt;Slowest: 0.0733 secs&lt;/td&gt;
&lt;td&gt;Fastest: 0.0027 secs&lt;/td&gt;
&lt;td&gt;Average: 0.0206 secs&lt;/td&gt;
&lt;td&gt;Requests/sec: 2420.4851&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total: 13.5070 secs&lt;/td&gt;
&lt;td&gt;Slowest: 0.3635 secs&lt;/td&gt;
&lt;td&gt;Fastest: 0.0249 secs&lt;/td&gt;
&lt;td&gt;Average: 0.0674 secs&lt;/td&gt;
&lt;td&gt;Requests/sec: 740.3558&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total: 1.8324 secs&lt;/td&gt;
&lt;td&gt;Slowest: 0.0269 secs&lt;/td&gt;
&lt;td&gt;Fastest: 0.0024 secs&lt;/td&gt;
&lt;td&gt;Average: 0.0091 secs&lt;/td&gt;
&lt;td&gt;Requests/sec: 5457.2339&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total: 1.5592 secs&lt;/td&gt;
&lt;td&gt;Slowest: 0.0211 secs&lt;/td&gt;
&lt;td&gt;Fastest: 0.0017 secs&lt;/td&gt;
&lt;td&gt;Average: 0.0078 secs&lt;/td&gt;
&lt;td&gt;Requests/sec: 6413.6480&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  ⚡ Current features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Written in Rust, btw xD&lt;/li&gt;
&lt;li&gt;A multithreaded Runtime&lt;/li&gt;
&lt;li&gt;Extensible&lt;/li&gt;
&lt;li&gt;A simple API&lt;/li&gt;
&lt;li&gt;Sync and Async Function Support&lt;/li&gt;
&lt;li&gt;Dynamic URL Routing&lt;/li&gt;
&lt;li&gt;Multi Core Scaling&lt;/li&gt;
&lt;li&gt;WebSockets!&lt;/li&gt;
&lt;li&gt;Hot Reloading&lt;/li&gt;
&lt;li&gt;Middlewares&lt;/li&gt;
&lt;li&gt;Community First and truly FOSS!&lt;/li&gt;
&lt;li&gt;Under active development!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔮 Future Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add typing support&lt;/li&gt;
&lt;li&gt;Document the process of plugin creation&lt;/li&gt;
&lt;li&gt;Create some plugins(e.g. for various Database providers like PgSQL, Mongo,etc.)&lt;/li&gt;
&lt;li&gt;Increase the execution speed.&lt;/li&gt;
&lt;li&gt;Better documentation&lt;/li&gt;
&lt;li&gt;Spend more time improving the Community and Ecosystem.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👣 A short history about robyn.
&lt;/h2&gt;

&lt;p&gt;It was April of 2021 and I was in the final year of my university. My final year project deadline was approaching and like any other hard-working student, I was spending all my time scrolling reddit. During that time, Reddit's CS threads were being flooded with "Rewrite in Rust" memes. And since I was such a hardworking student, I was working on a completely unrelated project which had a flask backend. &lt;/p&gt;

&lt;p&gt;Also, having written some backends in JavaScript from time to time, I used to really miss async methods while writing flask. That is when I told myself, you know Sanskar(yes sometimes I talk to myself in 3rd person) what would be cool: &lt;strong&gt;If you could create an Async Flask&lt;/strong&gt;(I had used FastAPI at that time but it was not a regular part of my dev toolkit).&lt;/p&gt;

&lt;p&gt;You know what would be cooler: &lt;strong&gt;IF IT WOULD BE WRITTEN IN RUST, BTW xD&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;And this is how Robyn was born.&lt;/p&gt;

&lt;h2&gt;
  
  
  Acknowledgements
&lt;/h2&gt;

&lt;p&gt;Thank you to all the people involved in the development of Robyn. From creating libraries over which robyn is built, to helping me out with rust queries to contributing and reviewing code. Thank you to everyone who is helping out with the project. 💖&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We are always eager for new contributors and support. Consider starring us for increased visibility.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sansyrox/robyn" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fgithub%2Fstars%2Fsansyrox%2Frobyn%3Fstyle%3Dsocial" alt="stars - robyn"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Vim-Python-VirtualEnv: A Plugin to manage Virtual Environments in Python</title>
      <dc:creator>Sanskar Jethi</dc:creator>
      <pubDate>Wed, 04 Nov 2020 08:12:37 +0000</pubDate>
      <link>https://forem.com/sansyrox/vim-python-virtualenv-a-plugin-to-manage-virtual-environments-in-python-54c</link>
      <guid>https://forem.com/sansyrox/vim-python-virtualenv-a-plugin-to-manage-virtual-environments-in-python-54c</guid>
      <description>&lt;p&gt;I love Vim ❤️ , especially NeoVim. I can write pages about why you should love it too. &lt;/p&gt;

&lt;p&gt;Python, being my daily driver makes the Vim Integration a match made in heaven ❤️&lt;/p&gt;

&lt;p&gt;There is one thing that annoyed me when I was working with Vim and Python. The &lt;code&gt;virtualenvs&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Since I don't want my python environment to be like one of the infected monsters from The Last of Us, I use &lt;code&gt;venvs&lt;/code&gt; for my projects. You should use them too!&lt;/p&gt;

&lt;p&gt;However, when if I boot my NeoVim from the Venv activated session, NeoVim did not recognize the Venv specific imports. &lt;br&gt;
Some extensions also conflicted with the between the local and the global python config.&lt;/p&gt;

&lt;p&gt;Like this:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fslbc0q3ft0rlw26fmjo6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fslbc0q3ft0rlw26fmjo6.png" alt="Screenshot 2020-11-04 at 1.01.54 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I tried looking for many extensions that would handle it automatically for me, but all of them wanted me to manually activate the &lt;code&gt;venvs&lt;/code&gt; from inside the Vim session. &lt;/p&gt;

&lt;p&gt;I wouldn't have become a software developer if I wanted to do everything myself, right? *cries internally*&lt;/p&gt;

&lt;p&gt;This is when I decided to write the plugin myself.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Process:
&lt;/h2&gt;

&lt;p&gt;With all the learning curves associated with Vim, a plugin always felt like the magic package which only TPope curated. &lt;/p&gt;

&lt;p&gt;But surprisingly, writing a plugin is a fairly simple process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;----Plugin-Folder/
  --plugins/
    --xyz.vim
  --README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vim has certain predefined files/folders which it looks out for while executing a plugin. You need to have a &lt;code&gt;plugins&lt;/code&gt; folder and a &lt;code&gt;README&lt;/code&gt; file. Vim will automatically execute all the files ending with &lt;code&gt;*.vim&lt;/code&gt; in the &lt;code&gt;Plugin&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;That's it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Vim-Python-VirtualEnv
&lt;/h2&gt;

&lt;p&gt;The goal of this plugin was to see add the venv configs in the vim session if the Virtual Environment was enabled for the terminal session.&lt;/p&gt;

&lt;p&gt;This in theory is fairly simple.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check if the venv is activated.&lt;/li&gt;
&lt;li&gt;Update the venv config from the &lt;code&gt;vim.rc&lt;/code&gt; or the &lt;code&gt;init.vim&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While reading the vim plugin docs, I found out that we can write vim plugins in Python too. This made it even better. 🤤&lt;/p&gt;

&lt;p&gt;Here is the code for the entire plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 &amp;lt;&amp;lt; EOF
import os
import subprocess

if "VIRTUAL_ENV" in os.environ:
    project_base_dir = os.environ["VIRTUAL_ENV"]
    script = os.path.join(project_base_dir, "bin/activate")
    pipe = subprocess.Popen(". %s; env" % script, stdout=subprocess.PIPE, shell=True)
    output = pipe.communicate()[0].decode('utf8').splitlines()
    env = dict((line.split("=", 1) for line in output))
    os.environ.update(env)

EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code searches for the &lt;code&gt;activate&lt;/code&gt; shell script which is commonly found in the &lt;code&gt;venv/bin&lt;/code&gt;, executes it, and updates the config in the session.&lt;/p&gt;

&lt;h3&gt;
  
  
  That's it!
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can install the extension using Vim Plug or any other plugin manager, e.g.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Plug 'sansyrox/vim-python-virtualenv'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can check out the plugin on GitHub through this link: &lt;a href="https://github.com/sansyrox/vim-python-virtualenv" rel="noopener noreferrer"&gt;https://github.com/sansyrox/vim-python-virtualenv&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  That's all folks!
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Any feedback is much appreciated! ✨&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Connect with me on twitter :)&lt;/p&gt;



&lt;blockquote&gt;
&lt;br&gt;
&lt;p&gt;"If Life is a Search for Meaning, it better be Binary Search." &lt;br&gt;&lt;br&gt;Amen.&lt;/p&gt;— Sanskar Jethi (&lt;a class="mentioned-user" href="https://dev.to/sansyrox"&gt;@sansyrox&lt;/a&gt;) &lt;a href="https://twitter.com/sansyrox/status/1314291406421155840?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;October 8, 2020&lt;/a&gt;&lt;br&gt;
&lt;/blockquote&gt; 

</description>
      <category>vim</category>
      <category>python</category>
      <category>tutorial</category>
      <category>firstpost</category>
    </item>
  </channel>
</rss>
