Articles on AbdelrahmanKhaled's Bloghttps://blogs.python-gsoc.orgUpdates on different articles published on AbdelrahmanKhaled's BlogenFri, 26 Aug 2022 18:37:21 +0000week - 11https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-11-4/<p><span style=""><strong>PRs</strong></span></p> <ul> <li> <h5><a href="https://github.com/lcompilers/lpython/pull/1012">Strings methods: <code>find()</code> #1012</a><span style=""> (open)</span></h5> </li> <li><span style=""><a href="https://github.com/lcompilers/lpython/pull/1039">Strings methods: <code>swapcase()</code></a> #1039 (open)</span></li> <li> <h5><span style=""><a href="https://github.com/lcompilers/lpython/pull/1049">Strings methods: <code>startswith()</code></a> #1049(open)</span></h5> </li> <li> <h5><span style=""><a href="https://github.com/lcompilers/lpython/pull/1001">Strings methods: <code>lstrip()</code></a>, <a href="https://github.com/lcompilers/lpython/pull/1001"><code>rstrip()</code></a>, <a href="https://github.com/lcompilers/lpython/pull/1001"><code>strip()</code></a> #1001 (closed)</span></h5> </li> <li> <h5><span style=""><a href="https://github.com/lcompilers/lpython/pull/954">strings: capialize, lower #954 </a>(closed)</span></h5> </li> <li><span style=""><a href="https://github.com/lcompilers/lpython/pull/954">strings: capialize, lower #954 </a>(closed)</span></li> <li> <h1><span style=""><a href="https://github.com/lcompilers/lpython/pull/684">Basic benchmark #684(open)</a></span></h1> </li> </ul> <h1><span style=""><b>Problems Faced This Week</b></span></h1> <p>I didn't face any major problems this week.</p> <p><strong>Next week</strong></p> <p>i will start with interactivity.</p> <p> </p>abdokh950@gmail.com (AbdelrahmanKhaled)Fri, 26 Aug 2022 18:37:21 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-11-4/Week-11https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-11-3/abdokh950@gmail.com (AbdelrahmanKhaled)Fri, 26 Aug 2022 18:30:53 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-11-3/Week - 10https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-10-3/<p><span style=""><strong>PRs</strong></span></p> <ul> <li> <h1><span style=""><a href="https://github.com/lcompilers/lpython/pull/954">strings capitalize</a> (open)</span></h1> </li> <li> <h1><span style=""><a href="https://github.com/lcompilers/lpython/pull/684">Basic benchmark #684</a> (open) (continuing)</span></h1> </li> </ul> <h1><span style=""><b>Problems Faced This Week</b></span></h1> <p><span style="">I didn't face any major problems this week.</span></p> <p><span style=""><strong>Next week</strong></span></p> <p><span style="">i will continue with strings features, and start with interactivity.</span></p>abdokh950@gmail.com (AbdelrahmanKhaled)Fri, 19 Aug 2022 21:58:02 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-10-3/Week - 09https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-09/<p><span style="font-size: 18px;"><strong>PRs</strong></span></p> <ul> <li> <h1><span style="font-size: 18px;"><a href="https://github.com/lcompilers/lpython/pull/954">strings capitalize</a> (open)</span></h1> </li> <li><span style="font-size: 18px;"><strong><a href="https://github.com/lcompilers/lpython/pull/875">Add bit_length() for integers</a></strong> (<strong>closed</strong>)</span></li> <li> <h1><span style="font-size: 18px;"><a href="https://github.com/lcompilers/lpython/pull/855">[README] Add rebasing example</a> (closed)</span></h1> </li> <li> <h1><span style="font-size: 18px;"><a href="https://github.com/lcompilers/lpython/pull/684">Basic benchmark #684</a> (open) (continuing)</span></h1> </li> </ul> <p><span style="font-size: 18px;">Issues:</span></p> <ul> <li> <h1><span style="font-size: 18px;"><a href="https://github.com/lcompilers/lpython/issues/881"><code>str</code> casting problems with bool, str #881</a></span></h1> </li> <li> <h1><span style="font-size: 18px;"><a href="https://github.com/lcompilers/lpython/issues/892">Redeclaration within different scopes #892</a></span></h1> </li> </ul> <h1><span style="font-size: 18px;"><b>Problems Faced This Week</b></span></h1> <p><span style="font-size: 18px;">I didn't face any major problems this week.</span></p> <p><span style="font-size: 18px;"><strong>Next week</strong></span></p> <p><span style="font-size: 18px;">i will continue with strings features, and start with interactivity.</span></p>abdokh950@gmail.com (AbdelrahmanKhaled)Fri, 12 Aug 2022 21:24:50 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-09/Week - 08https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-08/<p><span style="font-size: 18px;"><strong>PRs</strong></span></p> <ul> <li> <h1><span style="font-size: 18px;"><a href="https://github.com/lcompilers/lpython/pull/797">Add <code>str()</code> to casting #797</a> (closed</span><span style="font-size: 18px;">)</span></h1> </li> <li> <h1><span style="font-size: 18px;"><a href="https://github.com/lcompilers/lpython/pull/684">Basic benchmark #684</a> (open) (continuing)</span></h1> </li> </ul> <h1><span style="font-size: 18px;"><b>Problems Faced This Week</b></span></h1> <ul> <li><span style="font-size: 18px;">I didn't face any major problems this week</span></li> </ul> <p><strong><span style="font-size: 18px;">​​​​​​​Next week</span></strong></p> <p><span style="font-size: 16px;">i will continue woth strings features</span></p>abdokh950@gmail.com (AbdelrahmanKhaled)Thu, 11 Aug 2022 19:49:39 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-08/Week - 07https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-07/<p><strong><span style="font-size: 20px;">PRs</span></strong></p> <ul> <li> <h1><span style="font-size: 16px;"><a href="https://github.com/lcompilers/lpython/pull/797">Add <code>str()</code> to casting #797(open)</a></span></h1> </li> <li> <h1><span style="font-size: 16px;"><a href="https://github.com/lcompilers/lpython/pull/684">Basic benchmark #684</a> (open) (continuing)</span></h1> </li> </ul> <h1><span style="font-size: 18px;"><b>Problems Faced This Week</b></span></h1> <ul> <li><span style="font-size: 16px;">I didn't face any major problems this week.</span></li> </ul>abdokh950@gmail.com (AbdelrahmanKhaled)Thu, 11 Aug 2022 18:39:48 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-07/Week-06https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-06/<p><span style="font-size: 16px;">PRs:</span></p> <ul> <li> <h1><span style="font-size: 14px;"><a href="https://github.com/lcompilers/lpython/pull/767">Make <code>str()</code> work for non-constant values #767 </a>(closed)</span></h1> </li> <li> <h1><span style="font-size: 14px;"><a href="https://github.com/lcompilers/lpython/pull/800">[Draft] Add str to visit_ListItem #800</a> (open) (just a try)</span></h1> </li> <li> <h1><span style="font-size: 14px;"><a href="https://github.com/lcompilers/lpython/pull/797">Add str() for f32 (naive algo) #797</a> (open)</span></h1> </li> <li> <h1><span style="font-size: 14px;"><a href="https://github.com/lcompilers/lpython/pull/684">Basic benchmark #684</a> (open) (continuing)</span></h1> </li> </ul> <div style=""><span style="display: none;"> </span></div> <p><span style="font-size: 16px;">Now we have genreating section in benchmark:</span></p> <pre><code class="language-bash">benchmark/ ├── benchmark.toml ├── generated_code │   ├── long_statement.py │   └── very_long_statement.py ├── generating_scripts │   ├── long_statement.py │   └── very_long_statement.py ├── report_file.dat └── test_math.py </code></pre> <p><span style="font-size: 16px;">and that will help us with big source code(and genrated code will be ignored from git).</span></p>abdokh950@gmail.com (AbdelrahmanKhaled)Sat, 23 Jul 2022 16:18:05 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-06/Week-05https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-05/<ul> <li><span style="font-size: 18px;">i've finished StringCompersion.</span></li> <li><span style="font-size: 18px;">i fixed bug in str() function, i tried to fix it by implementing string elements for lists, and i'll continue with it next week.</span></li> <li><span style="font-size: 18px;">benchmark: ready to reviewing and merged.</span></li> </ul>abdokh950@gmail.com (AbdelrahmanKhaled)Sat, 16 Jul 2022 16:25:57 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-05/Week-04https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-04/<p>opened pr:</p> <p>1 - <a href="https://github.com/lcompilers/lpython/pull/744">StringsCompare</a>: edit comparison to be to on full strings, but there are some problems.</p> <pre><code class="language-python">def f(): assert "ahmed" == "ahmed" assert "a" == "a" assert "ab" != "a" assert "a" &lt; "ab" assert "ab" &gt; "a" assert "a" &gt;= "a"</code></pre> <p> </p>abdokh950@gmail.com (AbdelrahmanKhaled)Fri, 08 Jul 2022 19:08:57 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-04/Week-03https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-03/<p>i didn't make anything this week due to my graduation project.</p>abdokh950@gmail.com (AbdelrahmanKhaled)Fri, 08 Jul 2022 19:02:06 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-03/Week-02https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-02/<p><span style="color: #000000;"><span style="font-size: 20px;">I've finished my exams in this week, and return to work on benchmark.</span></span></p> <p><span style="font-size: 24px;"><span style="color: #f1c40f;"><strong>Benchmark: </strong></span></span></p> <ul> <li><span style="color: #e74c3c;"><span style="font-size: 20px;">Using:</span></span> <ul> <li><span style="color: #000000;"><span style="font-size: 18px;">Benchmark will work in a generic way to compare between LPython and Python compilers in any stage you want (but now i implemented parsing stage, if any one want to add other stage to compare, it will be easy to be added).</span></span></li> <li><span style="color: #000000;"><span style="font-size: 18px;">Files structure is similar to testing strucutre:</span></span> <pre><code class="language-bash">. ├── benchmark │   ├── benchmark.toml │   ├── long_statment.py │   ├── report_file.dat │   ├── test_math.py │   └── very_long_statment.py └── run_benchmark.py </code></pre> <p><span style="color: #000000;"><span style="font-size: 18px;">we will add files we want to compare to benchmark dir and we will add file in toml file and specify what stage we want to compare: </span></span></p> <pre><code class="language-javascript">#Possible comparisons # parser: Parsing time [[benchmark]] filename = 'test_math.py' parser = true other_stage = true [[benchmark]] filename = 'long_statment.py' parser = true [[benchmark]] filename = 'very_long_statment.py' parser = true other_stage = true </code></pre> <p><span style="color: #000000;"><span style="font-size: 18px;">here we have files, and every file has comparison stages</span></span></p> <p><span style="color: #000000;"><span style="font-size: 18px;">we can imagine files like this:</span></span></p> <p style="text-align: center;"><img alt="" height="219" src="https://i.ibb.co/5cFL8tx/stages-set.png" width="600"></p> <p> </p> </li> <li> <p><span style="font-size: 18px;"><span style="color: #000000;">so</span> <span style="color: #27ae60;">parser</span> <span style="color: #000000;">comparison set has</span><span style="color: #16a085;"> </span><span style="color: #e67e22;">very_long_statment.py, long_statment.py</span><span style="color: #16a085;"> </span><span style="color: #000000;">and</span><span style="color: #16a085;"> </span><span style="color: #e67e22;">test_math.py</span><span style="color: #000000;">,</span><span style="color: #16a085;"> </span><span style="color: #000000;">thats mean we will compare between Lpython and python on (Parsing) stage by these files.</span></span></p> </li> <li> <p><span style="font-size: 18px;"><span style="color: #27ae60;">other_stage </span><span style="color: #000000;">comparison set has</span><span style="color: #e67e22;"> long_statment.py</span><span style="color: #000000;">, that mean we will compare betweeen LPython and python on (other_stage) stage by this file.</span></span></p> </li> <li> <p><span style="color: #000000;"><span style="font-size: 18px;">Output will be table or pars, and you will have args flags to choose what you want:</span></span></p> <pre><code class="language-bash">$ python3 run_benchmark.py parser comparison LPython is first raw, Python is second one. Time in ms. benchmark/test_math.py : ▏ 237.24T ▏ 741.59T benchmark/long_statment.py : ▏ 3.77 ▇▇ 22.98 benchmark/very_long_statment.py: ▇▇▇ 39.04 ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 570.24 File Name LPython Python ------------------------------- --------- ---------- benchmark/test_math.py 0.237236 0.741587 benchmark/long_statment.py 3.77516 22.9778 benchmark/very_long_statment.py 39.0398 570.236 </code></pre> <pre><code class="language-bash">$ python3 run_benchmark.py --help usage: run_benchmark.py [-h] [-n] [-p] [-c COMPARE [COMPARE ...]] Lpython benchmark options: -h, --help show this help message and exit -n, --numerical show results as numerical table -p, --plots show results as graph of pars -c COMPARE [COMPARE ...], --compare COMPARE [COMPARE ...] What stages you want to compare, for now we have['parser'] </code></pre> </li> </ul> </li> <li><span style="color: #e74c3c;"><span style="font-size: 20px;">Implementation:</span></span> <ul> <li><span style="color: #000000;"><span style="font-size: 18px;">For every stage we want to implement we should make a class for the stage and make two statics functions for get time(or any value we wnat to compare) for Lpython and python </span></span> <pre><code class="language-python">class Parser: @classmethod def get_lpython_result(cls, file_path): lpython_run = subprocess.Popen("lpython --new-parser --time-report " + file_path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: stdout = lpython_run.communicate()[0].decode('utf-8') parsing_value = re.search(r"\bParsing: .*ms\b", stdout)[0] parsing_value = parsing_value.replace("Parsing: ", '') parsing_value = parsing_value.replace('ms', '') parsing_value = float(parsing_value) except: parsing_value = None return parsing_value @classmethod def get_cpython_result(cls, file_path): input = open(file_path).read() t1 = clock() a = ast.parse(input, type_comments=True) t2 = clock() return float(t2 - t1) * 1000 </code></pre> <span style="font-size: 18px;"><span style="color: #000000;">here</span> <span style="color: #c0392b;">parser </span><span style="color: #000000;">class implementation.</span></span></li> <li><span style="font-size: 18px;"><span style="color: #000000;">I used </span><span style="background-color: #dddddd;">time-report</span><span style="background-color: #ffffff;"> <span style="color: #000000;">for getting times of stages in LPython.</span></span></span></li> </ul> </li> <li><span style="font-size: 18px;"><span style="background-color: #ffffff;"><span style="color: #c0392b;">Related pull requests:</span></span></span> <ul> <li><span style="font-size: 18px;"><span style="color: #000000;"><span style="background-color: #ffffff;"><a href="https://github.com/lcompilers/lpython/pull/684">Basic benchmark #684</a></span></span></span></li> </ul> </li> </ul>abdokh950@gmail.com (AbdelrahmanKhaled)Fri, 24 Jun 2022 12:49:11 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-02/Week-01https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-01/<p>This week i tried to get familer with asr-to-llvm specially llvm so, i tried to see this <a href="https://github.com/lcompilers/lpython/issues/197">pull request</a> and some resources of llvm and because of exams, I couldn't work on anything this first week.</p>abdokh950@gmail.com (AbdelrahmanKhaled)Sat, 18 Jun 2022 19:17:27 +0000https://blogs.python-gsoc.org/en/abdelrahmankhaleds-blog/week-01/