<?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>DEV Community: Rohil Varma</title>
    <description>The latest articles on DEV Community by Rohil Varma (@rohilvarma).</description>
    <link>https://dev.to/rohilvarma</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%2F746023%2F22cddaf6-5b5e-4289-b959-04dcd0cbb2db.jpg</url>
      <title>DEV Community: Rohil Varma</title>
      <link>https://dev.to/rohilvarma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rohilvarma"/>
    <language>en</language>
    <item>
      <title>Boost Python performance</title>
      <dc:creator>Rohil Varma</dc:creator>
      <pubDate>Sat, 14 Jan 2023 16:35:09 +0000</pubDate>
      <link>https://dev.to/rohilvarma/boost-python-performance-1cg8</link>
      <guid>https://dev.to/rohilvarma/boost-python-performance-1cg8</guid>
      <description>&lt;p&gt;Despite being one of the most popular scripting language. The primary disadvantage at hand with python is always performance. Owning to its dynamic nature and versatility, it takes a toll in the area of performance. Here a few tips that when incorporated in your code might help you improve the performance a bit:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Use the latest version of Python
&lt;/h4&gt;

&lt;p&gt;Using the latest version of python is always the better choice (as long as it doesn't break your existing application 😂) since it's updated and upgraded regularly, and every release is faster and more optimized. &lt;/p&gt;

&lt;h4&gt;
  
  
  2. Use List comprehension
&lt;/h4&gt;

&lt;p&gt;Being an easier syntax for appending in a list as compared to for loop and append(), it performs better as it doesn't needs to load the append attribute of the list and call it as a function in each iteration as it happens in the traditional case, thereby slowing as compared to dynamic list creation.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Use pyarrow
&lt;/h4&gt;

&lt;p&gt;Whenever you are loading a csv file in your code, always use the pyarrow engine. Here are some&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from time import time
from pandas import read_csv

print('Without pyarrow engine')
start = time()

df = read_csv('./custom_2020.csv')
print(df.shape)
end = time()

print("Execution", end-start)

print('With pyarrow engine')

start = time()
new_df = read_csv('./custom_2020.csv', engine='pyarrow')
print(df.shape)
end = time()
print('Execution', end-start)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4ep3rnra31882bt3zs4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4ep3rnra31882bt3zs4.png" alt="Performance comparision for a 218MB csv file" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Always use in-built functions
&lt;/h4&gt;

&lt;p&gt;In-built functions are always superior in terms of performance as compared to the custom functions because they are highly optimized. Moreover the custom functions are more prone to errors as compared to the in-built ones.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Always import the functions not the entire module
&lt;/h4&gt;

&lt;p&gt;Instead of using &lt;br&gt;
&lt;code&gt;import module&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;using &lt;br&gt;
&lt;code&gt;from module import xyz&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;offers slightly better performance as compared to the prior. Moreover its a good idea to distribute the imported packages all across the program instead of at the top. Though it may look like a good idea but for large scale projects, there might be cases of memory peaks when all the modules are loaded at once.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Concatenate strings with join
&lt;/h4&gt;

&lt;p&gt;Whenever we declare a string, a value is stored in the heap. So anytime we append to a respective string, the program has to first copy the entire string all over to the other place and then perform the append. using &lt;code&gt;' '.join(str)&lt;/code&gt;. This may look trivial but for huge applications it contains the potential to spike the memory usage.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. Use appropriate Data Structure
&lt;/h4&gt;

&lt;p&gt;Whenever working with any code it is extremely important to use the right Data Structure and the optimal algorithm that tailors around the use of the application. For instance, it would be stupid to use a &lt;em&gt;Stack&lt;/em&gt; instead of a &lt;em&gt;Queue&lt;/em&gt; when building a feature for queueing songs on a music app.&lt;/p&gt;




&lt;h3&gt;
  
  
  Wrapping Up
&lt;/h3&gt;

&lt;p&gt;While Python is an incredible language with a plethora of tools at our disposal, it is crucial to know the tools and the methods that would help us achieve higher performance. There are a lot of packages that use C bindings that make our code faster by leaps and bounds. I have listed all the methods that I feel are the most important and (should do the job) but that does not mean that this it. One must always explore all the options/alternatives available to them before fixing on one of the approaches.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webcomponents</category>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>create-react-app using Bash</title>
      <dc:creator>Rohil Varma</dc:creator>
      <pubDate>Sun, 10 Jul 2022 18:54:43 +0000</pubDate>
      <link>https://dev.to/rohilvarma/create-react-app-using-bash-1i9a</link>
      <guid>https://dev.to/rohilvarma/create-react-app-using-bash-1i9a</guid>
      <description>&lt;p&gt;Hi, this is my first post!&lt;/p&gt;

&lt;p&gt;This post I am going to share how to setup a React project using Bash&lt;/p&gt;

&lt;h2&gt;
  
  
  Why did I did what I did??
&lt;/h2&gt;

&lt;p&gt;I started using Ubuntu as my primary Operating System and eventually as any developer out there I came across the point when I had to start learning Bash. Scripting in Bash always felt fascinating but while I was on my learning ropes I wanted to create an actual script that could help me with my daily tasks.&lt;br&gt;
So one of the most mundane things beginners do while starting a React project is open up the terminal, navigate to location, enter &lt;code&gt;npx create-react-app xyz-project&lt;/code&gt;, wait for it to finish, enter the src and public and remove everything and then finally start. Since I was also on the initial stages of React, I didn't have much knowledge about all the other things that we could do but anyway.&lt;br&gt;
What my script does is, all we need to do is execute and enter the name of the project and whether we wanna install tailwind or not (I love Tailwind CSS and its my goto framework) and voila we're ready to start development.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
read -p "Enter the name of the project: " projectName
echo "#######################################"
echo "########### Starting Script ###########"
echo "#######################################"

#Change the directory according to wherever you store your development file
startupFolder='/home/brownie/Desktop/Development/react-startup-files'

npx create-react-app $projectName

cd $projectName

echo "This is the $projectName directory"

ls -la

echo "Removing src folder"

rm -r src/

mkdir src

cd src

touch index.js App.js index.css

mkdir components

echo "The new src/ directory"

for i in $(ls)
do
    echo $i
done

echo "Writing in the index.js"
cp $startupFolder/index.js index.js
cat index.js

echo "Writing in the App.js file" 
cp $startupFolder/App.js App.js
cat App.js

cd ..

echo "Removing public folder"

rm -r public/

mkdir public

cd public/

touch index.html

echo "The new public/ directory"

for i in $(ls)
do
    echo $i
done

echo "Writing index.html"
cp $startupFolder/index.html index.html
cp $startupFolder/favicon.ico ./
cat index.html

cd ..

read -p "Do you want to install Tailwind?(y/n) " tailwindChoice

if [[ "$tailwindChoice" == "y" ]]
then
    npm install -D tailwindcss postcss autoprefixer
    npx tailwindcss init -p

    echo "Writing the index.css file"
    cd src/
    cp $startupFolder/index.css index.css
    cat index.css

    echo "Writing the tailwind.config.js file"
    cd ..
    cp $startupFolder/tailwind.config.js tailwind.config.js
    cat tailwind.config.js
fi

echo "Removing Git Files"
sudo rm -r .git
rm .gitignore

read -p "Do you want to open in code?(y/n) " codeChoice

if [[ "$codeChoice" == "y" ]]
then
    code .
fi

echo "Closing Terminal"

exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ofcourse there can be a lot of modifications that can be made that being said its just a basic bash script to improve basic producivity workflow. &lt;br&gt;
Feel free to share your thoughts on how you would upgrade this script to better suit your needs&lt;/p&gt;

</description>
      <category>react</category>
      <category>codenewbie</category>
      <category>bash</category>
      <category>tailwindcss</category>
    </item>
  </channel>
</rss>
