Skip to content

Commit c73399a

Browse files
author
Anastasiia Shcherbakova
committed
Fixed US/British spelling mix-up and reduced the number of new paragraphs
1 parent a7a09ca commit c73399a

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

episodes/optimisation-introduction.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ exercises: 0
1919
## Introduction
2020

2121
<!-- Changing the narrative: you'd better learn how to write a good code an what are the good practice -->
22-
Think about optimization as the first step on your journey to writing high-performance code.
22+
Think about optimisation as the first step on your journey to writing high-performance code.
2323
It’s like a race: the faster you can go without taking unnecessary detours, the better.
2424
Code optmisation is all about understanding the principles of efficiency in Python and being conscious of how small changes can yield massive improvements.
2525

2626
<!-- Necessary to understand how code executes (to a degree) -->
27-
These are the first steps in code optimization: making better choices as you write your code and have an understanding of what a computer is doing to execute it.
27+
These are the first steps in code optimisation: making better choices as you write your code and have an understanding of what a computer is doing to execute it.
2828

2929
<!-- Goal is to give you a high level understanding of how your code executes. You don't need to be an expert, even a vague general understanding will leave you in a stronger position. -->
3030
A high-level understanding of how your code executes, such as how Python and the most common data-structures and algorithms are implemented, can help you identify suboptimal approaches when programming. If you have learned to write code informally out of necessity, to get something to work, it's not uncommon to have collected some bad habits along the way.
@@ -34,41 +34,25 @@ The remaining content is often abstract knowledge, that is transferable to the v
3434

3535
## Optimising code from scratch: trade-off between performance and maintainability
3636

37-
> Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: **premature optimization is the root of all evil**. Yet we should not pass up our opportunities in that critical 3%. - Donald Knuth
37+
> Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: **premature optimisation is the root of all evil**. Yet we should not pass up our opportunities in that critical 3%. - Donald Knuth
3838
39-
This classic quote among computer scientists states; when considering optimisation it is important to focus on the potential impact, both to the performance and maintainability of the code.
40-
41-
Advanced optimisations, mostly outside the scope of this course, can increase the cost of maintenance by obfuscating what code is doing. Even if you are a solo-developer working on private code, your future self should be able to easily comprehend your implementation.
42-
43-
Therefore, the balance between the impact to both performance and maintainability should be considered when optimising code.
39+
This classic quote among computer scientists states; when considering optimisation it is important to focus on the potential impact, both to the performance and maintainability of the code. Advanced optimisations, mostly outside the scope of this course, can increase the cost of maintenance by obfuscating what code is doing. Even if you are a solo-developer working on private code, your future self should be able to easily comprehend your implementation. Therefore, the balance between the impact to both performance and maintainability should be considered when optimising code.
4440

4541
This is not to say, don't consider performance when first writing code. The selection of appropriate algorithms and data-structures covered in this course form a good practice, simply don't fret over a need to micro-optimise every small component of the code that you write.
4642

47-
4843
## Ensuring Reproducible Results when optimising an existing code
4944

5045
<!-- This is also good practice when optimising your code, to ensure mistakes aren't made -->
5146
When optimising an existing code, you are making speculative changes. It's easy to make mistakes, many of which can be subtle. Therefore, it's important to have a strategy in place to check that the outputs remain correct.
5247

53-
Testing is hopefully already a seamless part of your research software development process.
54-
Test can be used to clarify how your software should perform, ensuring that new features work as intended and protecting against unintended changes to old functionality.
55-
56-
There are a plethora of methods for testing code.
48+
Testing is hopefully already a seamless part of your research software development process. Test can be used to clarify how your software should perform, ensuring that new features work as intended and protecting against unintended changes to old functionality.
5749

5850
## pytest Overview
5951

60-
Most Python developers use the testing package [pytest](https://docs.pytest.org/en/latest/), it's a great place to get started if you're new to testing code.
52+
There are a plethora of methods for testing code. Most Python developers use the testing package [pytest](https://docs.pytest.org/en/latest/), it's a great place to get started if you're new to testing code. Tests should be created within a project's testing directory, by creating files named with the form `test_*.py` or `*_test.py`. pytest looks for these files, when running the test suite. Within the created test file, any functions named in the form `test*` are considered tests that will be executed by pytest. The `assert` keyword is used, to test whether a condition evaluates to `True`.
6153

6254
Here's a quick example of how a test can be used to check your function's output against an expected value.
6355

64-
Tests should be created within a project's testing directory, by creating files named with the form `test_*.py` or `*_test.py`.
65-
66-
pytest looks for these files, when running the test suite.
67-
68-
Within the created test file, any functions named in the form `test*` are considered tests that will be executed by pytest.
69-
70-
The `assert` keyword is used, to test whether a condition evaluates to `True`.
71-
7256
```python
7357
# file: test_demonstration.py
7458

0 commit comments

Comments
 (0)