Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7825ca0

Browse files
author
boris
committed
Proofread blog posts
1 parent7b1a389 commit7825ca0

File tree

5 files changed

+42
-43
lines changed

5 files changed

+42
-43
lines changed

‎_config.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# in the templates via {{ site.myvariable }}.
2020

2121
title:"RustPython"
22-
description:"An open source Python-3 (CPython >= 3.5.0)Interpreter written in Rust 🐍 😱 🤘"
22+
description:"An open source Python3 (CPython >= 3.5.0)interpreter written in Rust 🐍 😱 🤘"
2323
# baseurl: "/" # the subpath of your site, e.g. /blog
2424
url:"https://rustpython.github.io"# the base hostname & protocol for your site, e.g. http://example.com
2525
github_username:RustPython
@@ -29,7 +29,7 @@ docs: https://github.com/RustPython/docs/
2929
gitter:https://gitter.im/rustpython/Lobby
3030
show_excerpts:true
3131
contributor_excerpt:""# TODO: write something here, goes right under "Contributors" heading
32-
blog-intro:Create an issue if youread something wrong. Edit posts or create new ones via PR on <a href="https://github.com/RustPython/rustpython.github.io">github.com/RustPython/rustpython.github.io</a>
32+
blog-intro:Create an issue if yousee something wrong. Edit posts or create new ones via PR on <a href="https://github.com/RustPython/rustpython.github.io">github.com/RustPython/rustpython.github.io</a>
3333

3434
navigation:
3535
-title:Blog

‎_posts/2020-03-12-thing-explainer-parser.markdown‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ date: 2020-04-02 11:34:01 -0400
66

77
This post goes over the RustPython parser. You can see the source code at[RustPython/parser/](https://github.com/RustPython/RustPython/tree/master/parser).
88

9-
When you write code inpython and run it, an interpreter, such as the RustPython interpreter, acts as the translator between you and your machine.
9+
When you write code inPython and run it, an interpreter, such as the RustPython interpreter, acts as the translator between you and your machine.
1010

11-
The interpreter has the job of turning your human code intobyte codethat apython virtual machine can run. Bytecode is an intermediate code between source code and machine code. This makes it portable across multiple hardware and operating systems. Bytecode "works" as long as you implement a virtual machine(vm) that can run it. There is a performance penalty for this flexibility. RustPython has a vm under[RustPython/vm/](https://github.com/RustPython/RustPython/tree/master/vm). Other posts, will go into the details of that vm but now let's figure out how to turn code into bytecode.
11+
The interpreter has the job of turning your human code intobytecodethat aPython virtual machine can run. Bytecode is an intermediate code between source code and machine code. This makes it portable across multiple hardware and operating systems. Bytecode "works" as long as you implement a virtual machine(vm) that can run it. There is a performance penalty for this flexibility. RustPython has a vm under[RustPython/vm/](https://github.com/RustPython/RustPython/tree/master/vm). Other posts will go into the details of that vm but now let's figure out how to turn code into bytecode.
1212

1313

14-
##How doesbytecodelook like
14+
##Whatbytecodelooks like
1515

16-
Seeing is believing. To see what bytecode looks like, you can use a Python module called[`dis`](https://docs.python.org/3/library/dis.html). dis standsfordisassembler. You can write source code then see how its bytecode looks like. Here is an example:
16+
Seeing is believing. To see what bytecode looks like, you can use a Python module called[`dis`](https://docs.python.org/3/library/dis.html)."dis" is short offor_dis_assembler. You can write source code then see how its bytecode looks like. Here is an example:
1717

1818
![bytecode](/assets/media/bytecode.jpg)
1919

2020

21-
##How RustPython turns your codeto bytecode
21+
##How RustPython turns your codeinto bytecode
2222

23-
Here are the main steps that RustPython currentlydoes:
23+
Here are the main steps that RustPython currentlygoes through:
2424
- parse the line of source code into tokens
2525
- determine if the tokens have a valid syntax
2626
- create an Abstract Syntax Tree (AST)
@@ -31,7 +31,7 @@ This list of steps introduces some new concepts like: tokens and abstract syntax
3131

3232
###Step 1: parsing source code into tokens
3333

34-
The fastest way to understand what tokens are, is to see them. Conveniently, Python comes with a[tokenizer](https://docs.python.org/3/library/tokenize.html).Here is whathappen if I run the tokenizer on the function that I createdearlier.
34+
The fastest way to understand what tokens are, is to see them. Conveniently, Python comes with a[tokenizer](https://docs.python.org/3/library/tokenize.html). Here is whathappens if I run the tokenizer on the function that I createdabove.
3535

3636
`$ python -m tokenize file.py`
3737

@@ -46,20 +46,20 @@ def add(x,y):
4646
![tokenzizing](/assets/media/tokenizing.jpg)
4747

4848

49-
A picture IS worth a thousandword 😛 Those are the tokens. They are the basic "units"in the programming language. They are the keywords and operators that you typed. Even new lines andidentations count.
49+
A picture IS worth a thousandwords 😛 Those are the tokens. They are the basic "units"of the programming language. They are the keywords and operators that you typed. Even new lines andidentation count.
5050

5151
If you want to sound fancy:
5252
- The tokens are the basic "lexical components"
5353
- The parsing process is called "lexical analysis"
54-
- The thing that doesthe process is a "lexer"
54+
- The thing that doesthis is a "lexer"
5555

5656
Here is the link to the RustPython lexer.
5757

5858
**`RustPython/parser/lexer.rs`** >>
5959
[source code](https://github.com/RustPython/RustPython/blob/master/parser/src/lexer.rs)
6060

6161

62-
If you want dive into the details of lexical analysis, check out[Python in a nutshell / Lexical structure](https://learning.oreilly.com/library/view/python-in-a/9781491913833/ch03.html#python_language-id00003)
62+
If you wanttodive into the details of lexical analysis, check out[Python in a nutshell / Lexical structure](https://learning.oreilly.com/library/view/python-in-a/9781491913833/ch03.html#python_language-id00003)
6363

6464

6565
###Step 2 : determine if the tokens are valid syntax
@@ -70,8 +70,8 @@ In the previous step, if you add random stuff to your function and tokenize it,
7070

7171
So don't hate on the whole interpreter when you get error messages! or at least don't hate on the tokenizer!
7272

73-
To determine if the tokens are valid syntax, first you need a definition of what a valid syntax is. Python has a defined "grammar" or set of rules. The official reference is on[this link](https://docs.python.org/3/reference/grammar.html). There, you will find a machine readable file. You may read a book to know the rules ofpython, but words are too "fluffy", an algorithm that verifies if rules are followed needs a very strict set of rules encoded in a file.[This video](https://www.youtube.com/watch?v=KGMFvy2d5OI) explains the Python grammar and the file's notation.
74-
As the presenter puts it, this is the spirit of the beast (python) and it is only~10KB 😭 (compare that to the size ofpython books you had to read!)
73+
To determine if the tokens are valid syntax, first you need a definition of what a valid syntax is. Python has a defined "grammar" or set of rules. The official reference is on[this link](https://docs.python.org/3/reference/grammar.html). There, you will find a machine readable file. You may read a book to know the rules ofPython, but words are too "fluffy", an algorithm that verifies if the rules are followed needs a very strict set of rules encoded in a file.[This video](https://www.youtube.com/watch?v=KGMFvy2d5OI) explains the Python grammar and the file's notation.
74+
As the presenter puts it, this is the spirit of the beast (Python) and it is only~10KB 😭 (compare that to the size ofthe Python books you had to read!)
7575

7676
So, we have the rules or grammar of a programming language in a machine encoded format... now we need to write something that verifies that those rules were followed... This sounds like something that other people could use and like something that should exist as an open source project! 🤔
7777

@@ -91,7 +91,7 @@ You can do:
9191

9292
##Recap 🥴 🥵
9393

94-
As a recap, when you write a line ofpython code and "run it", here is what the RustPython interpreter does:
94+
As a recap, when you write a line ofPython code and "run it", here is what the RustPython interpreter does:
9595

9696
**INPUT: your code** (in`file.py` or interactive shell)
9797
⬇️ parse the line of source code into tokens
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
11
---
22
layout:post
3-
title:"How to contribute to RustPythonby CPython unittest"
3+
title:"How to contribute to RustPythonusing CPython's unit tests"
44
date:2020-04-05 01:45:00 +0900
55
categories:[guideline, featured]
66
permalink:guideline/2020/04/04/how-to-contribute-by-cpython-unittest.html
77
---
88

9-
At the very end of 2019, we finally reached one ofthe short-term goals: CPython unittest support. Due to this enhancement,finding CPython compatibilityis easier thanbefore.
10-
Probably thiswill be the major source ofcontribution spotsfor the new contributors this year. Here is a simple guideline.
9+
At the very end of 2019, we finally reached one ofour short-term goals: CPython`unittest` support which makesfinding CPython compatibilityerrors easier thanever.
10+
Thiswillprobablybe the major source ofcontributionsfor new contributors this year. Here is a simple guideline.
1111

1212
##Fix known compatibility bugs
1313
Let's find an incompatibility issue and fix it.
14-
15-
1. See`Lib/test` directory of the project. There are many`test_` prefixed files like`test_unicode.py`.
14+
1. Look at the`Lib/test` directory of the project. There are many`test_` prefixed files like`test_unicode.py`.
1615
2. Try to open one of them. It might look just fine at a glance - but search for`TODO: RUSTPYTHON` in the files. There are tons of skipped, marked as an expected failure or commented out tests.
17-
1. Alternatively, try looking at the[regressiontests results]({% link pages/regression-tests-results.markdown %}) to find skipped or expected failure tests; some of them have
16+
1. Alternatively, try looking at the[regressiontest results]({% link pages/regression-tests-results.markdown %}) to find skipped or expected failure tests; some of them have
1817
notes for a way to resolve the issue.
19-
3. Choose one or two interesting bugs. Remove the test blocker - skip,expectedFailure or comments.
18+
3. Choose one or two interesting bugs. Remove the test blocker -`skip`,`expectedFailure` or comments.
2019
4. Try to fix them.
2120

22-
Here is a quick tip torun single unittest file.
21+
Here's how yourunasingle unittest file:
2322

24-
`$ RUSTPYTHONPATH=Lib cargo run --release Lib/test/test_unicode.py`
23+
`$ RUSTPYTHONPATH=Lib cargo run --release Lib/test/test_unicode.py`
2524

2625
##Add a new unittest file
27-
Because CPython unittestis notperfectlyworkingin RustPython, we aredoing thisone by one with editings.
28-
1. Download CPython source code.
29-
2. Check out a specific version of CPython.For now,3.8.2 is recommended. (We are testing against CPython3.8and 3.8.2 isthe most recent version for now)
30-
3. Copy a file from CPython`Lib/test`
31-
4. Commit the file without editing. Specifycopied CPython versionto commit message.
26+
Because CPython unittestdoesn't work workperfectly in RustPython, we areadding test filesone by one. Here's how:
27+
1. DownloadtheCPython source code with`git clone https://github.com/python/cpython.git`.
28+
2. Check out a specific version of CPython.We test against CPython3.8, so the most recent release of3.8([currently 3.8.7](https://www.python.org/doc/versions/)) isrecommended.
29+
3. Copy a file from CPython's`Lib/test`
30+
4. Commit the file without editing it. Specifythe CPython versionyou copied from in the commit message.
3231
5. Try to edit it until it runs without a crash or failure.
3332
6. Commit the changes to make it run. This is the core contribution.
3433

35-
Because RustPython is not perfect, "try to edit it until it runs" doesn't mean to make 100%successful running. The commoneditingmethodshere:
36-
1.At least it must be able to start to run thetest. Fix the test code or bug until it runs at least a single unit of the test. Typically, unimplemented stdlib or missing filesofunittest canmake issues. Sometimes RustPython bugsmake issues too.
37-
2. If any testis not loadable by`SyntaxError`,that part is requiredtobe commented out.
38-
3. If any test leads to a crash of RustPython, this codeis not possible torun. Mark the test to skip.
39-
4. If any testis runbut fails, this is an incompatibility issue. Mark the test as an expected failure.
34+
Because RustPython is not perfect, "try to edit it until it runs" doesn't mean to makeit run100%of the tests successfully. The common methodsto make the test file pass are:
35+
1.It must at least be able to start to run thetests. Fix the test code or bug until it runs at least a single unit of the test. Typically, unimplemented stdlib or missing filesin`unittest` cancause issues. Sometimes RustPython bugscause issues too.
36+
2. If any testcan't be loaded because of a`SyntaxError`,you'll havetocomment that part out.
37+
3. If any test leads to a crash of RustPython, this codecan't berun. Mark the testwith`@unittest.skip('TODO: RUSTPYTHON')`to skip it.
38+
4. If any testrunsbut fails, this is an incompatibility issue. Mark the test as an expected failure with`@unittest.expectedFailure`.
4039

41-
We prefer the reversed order ofupper methods. The later the more strict soeasy to detect any progress or regression.
42-
When we temporarily disable parts of unittest due to RustPython caveats, we mark them tofind itout easilylater. Pleasecheck the examples below or search for`TODO: RUSTPYTHON` in`Lib/test` directory to check actual usage.
40+
We prefer the reversed order ofabove methods. The later, the more strict, soit's easier to detect any progress or regression.
41+
When we temporarily disable parts of`unittest` due to RustPython caveats, we mark them tomake iteasier to find (and re-enable!) themlater. Pleasesee the examples below or search for`TODO: RUSTPYTHON` in the`Lib/test` directory to check actual usage.
4342

4443
Comment out:
4544
```python
@@ -48,18 +47,18 @@ Comment out:
4847
# def ... # commented out tests
4948
```
5049

51-
skip:
50+
`skip`:
5251
```python
5352
@unittest.skip("TODO: RUSTPYTHON")
5453
def...# skipped tests
5554
```
5655

57-
expectedFailure:
56+
`expectedFailure`:
5857
```python
5958
#TODO: RUSTPYTHON
6059
@unittest.expectedFailure
6160
def...# failed tests
6261
```
6362

6463
##Development guide
65-
Forthe generalsource of the development, please visit the[RustPython development guide](https://github.com/RustPython/RustPython/blob/master/DEVELOPMENT.md)
64+
Fora generalintroduction to RustPython development, please visit the[RustPython development guide](https://github.com/RustPython/RustPython/blob/master/DEVELOPMENT.md)

‎index.markdown‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ installation:
2626

2727
goals:
2828
-goal:
29-
Full Python-3 environment entirely in Rust (not CPython bindings), with
29+
Full Python3 environment entirely in Rust (not CPython bindings), with
3030
a clean implementation and no compatiblity hacks.
3131
# TODO: integrate this into the "goals" boxes
3232
progress:
@@ -53,10 +53,10 @@ There are many implementations of Python. For example:
5353
-[PyPy](https://www.pypy.org/) (Python)
5454
-[Stackless](http://www.stackless.com/)
5555

56-
Each of these implementations offer some benefits: Jython, for example, compiles Python source code to Java byte code, then routes it to the Java Virtual Machine. Because Python code is translated to Javabyte code, it looks and feels like a true Java program at runtime and so it integrates well with Java applications.
56+
Each of these implementations offer some benefits: Jython, for example, compiles Python2source code to Java byte code, then routes it to the Java Virtual Machine. Because Python code is translated to Javabytecode, it looks and feels like a true Java program at runtime and so it integrates well with Java applications.
5757

5858
IronPython is well-integrated with .NET, which means IronPython can use the .NET framework and Python libraries or vice versa.
5959

6060
We want to unlock the same possibilities that Jython and IronPython enable, but for the Rust programming language. In addition, thanks to Rusts' minimal runtime, we're able to compile RustPython to WebAssembly and allow users to run their Python code easily in the browser.
6161

62-
Check the "learn more" section for an explainer of all those jargon-y words, or read the blog for more in-depth technical discussion.
62+
Checkoutthe "learn more" section for an explainer of all those jargon-y words, or read the blog for more in-depth technical discussion.

‎manifest.webmanifest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"start_url":".",
55
"display":"standalone",
66
"theme_color":"#F74C00",
7-
"description":"An open source Python-3 (CPython >= 3.5.0) Interpreter written in Rust 🐍 😱 🤘"
7+
"description":"An open source Python3 (CPython >= 3.5.0) Interpreter written in Rust 🐍 😱 🤘"
88
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp