Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Greek small letter mu #14426

Merged
merged 2 commits into from May 7, 2024
Merged

Display Greek small letter mu #14426

merged 2 commits into from May 7, 2024

Conversation

covracer
Copy link
Contributor

@covracer covracer commented May 1, 2024

%time foo() output is often copied into code comments to explain
performance improvements. The \xb5 Latin Extended micro sign and the
\u03bc Greek small letter mu have different codes but often look
identical.

Output mu to align with:

python -c 'print("""class C:
    \xb5=1
print(hex(ord(dir(C)[-1])))""")' | tee /dev/fd/2 | python -
class C:
    µ=1
print(hex(ord(dir(C)[-1])))

0x3bc

...U+03BC μ is the preferred character in a Unicode context.

  • Ruff confusable mapping updates, currently in the "preview" stage

Add a unit test for UTF-8 display and
https://bugs.launchpad.net/ipython/+bug/348466 ASCII fallback.

@covracer covracer changed the title %time foo() output is often copied into code comments to explain Display Greek small letter mu May 1, 2024
@covracer covracer force-pushed the mu branch 4 times, most recently from 4307c3c to 2e07d9f Compare May 1, 2024 15:06
`%time foo()` output is often copied into code comments to explain
performance improvements. The `\xb5` Latin Extended micro sign and the
`\u03bc` Greek small letter mu have different codes but often look
identical.

Output mu to align with:

* [The International System of Units (SI) brochure](
  https://www.bipm.org/documents/20126/41483022/SI-Brochure-9-EN.pdf
  ), such as Table 7 SI prefixes
* NFKC normalized [Python code](https://peps.python.org/pep-3131/
  ) and [domain names](https://unicode.org/reports/tr36/). For example:
```sh
python -c 'print("""class C:
    \xb5=1
print(hex(ord(dir(C)[-1])))""")' | tee /dev/fd/2 | python -
```
```python
class C:
    µ=1
print(hex(ord(dir(C)[-1])))
```
`0x3bc`
* Section 2.5 Duplicated Characters of [Unicode Technical Report 25](
  https://www.unicode.org/reports/tr25/)
> ...U+03BC μ is the preferred character in a Unicode context.
* Ruff confusable mapping [updates](
  https://github.com/astral-sh/ruff/pull/4430/files
  ), currently in the "preview" stage

Add a unit test for UTF-8 display and
https://bugs.launchpad.net/ipython/+bug/348466 ASCII fallback.
@Carreau
Copy link
Member

Carreau commented May 6, 2024

Seem reasonable to me. Out of curiosity how did you came across this ?

@Carreau Carreau added this to the 8.25 milestone May 7, 2024
@Carreau Carreau merged commit 810faec into ipython:main May 7, 2024
16 of 19 checks passed
@covracer covracer deleted the mu branch May 7, 2024 12:30
@covracer
Copy link
Contributor Author

covracer commented May 7, 2024

I worked on a Django app with duplicate entries in its units model/table, one using micro and the other mu. Wanting a linter or autoformatter to prevent the confusion led me to Ruff. Ruff's "ecosystem" checks of Pandas led me to %time output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants