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

FAQ docs reformat. Minute Typos #3963

Closed
wants to merge 2,022 commits into from
Closed

FAQ docs reformat. Minute Typos #3963

wants to merge 2,022 commits into from

Conversation

rcghpge
Copy link

@rcghpge rcghpge commented Jan 23, 2025

Minute typos. mojo to Mojo.

helehex and others added 30 commits December 17, 2024 16:21
[External] [stdlib] Fix `/_math.mojo` examples.

FYI: `Truncable` is not in `math`, so that one still fails, not sure
what's going on there.

Co-authored-by: Helehex <[email protected]>
Closes modular#3681
MODULAR_ORIG_COMMIT_REV_ID: d1fb6af747e4599fe0eefa709dad1f9f4840e5b1
All of the internal code has moved over to using `Pointer` — the new
name, instead of `Reference`. Drop the compatibility type alias now.

MODULAR_ORIG_COMMIT_REV_ID: cda036aa01a5ec512dbeae1debfaba3a6f181298
…tor for performance and readability, and prepare for full format spec support (#49225)

[External] [stdlib] Fix `String.format()` to use byte indexing, refactor
for performance and readability, and prepare for full format spec
support

Fix `String.format()` to use byte indexing, refactor for performance and
readability, and prepare for full format spec support.

Closes modular#3296.

ORIGINAL_AUTHOR=martinvuyk
<[email protected]>
PUBLIC_PR_LINK=modular#3539

Co-authored-by: martinvuyk <[email protected]>
Closes modular#3539
MODULAR_ORIG_COMMIT_REV_ID: 2d7ebae6f48b7d29866c089cffd084cb4405ac45
[External] [stdlib] Improve readability of `test_python_object`

Instead of raw strings with some Python inline for types and methods,
pull them out into a separate Python module: `custom_indexable.py` and use that
within the test. This allows for better maintenance and readability by having the
code in a separate file.

Co-authored-by: Joshua James Venter <[email protected]>
Closes modular#3678
MODULAR_ORIG_COMMIT_REV_ID: c9a63e78e4d2f38401b6d344accd356dca89f9e6
[External] [stdlib] Fix example in `/floatable.mojo`

Co-authored-by: Helehex <[email protected]>
Closes modular#3679
MODULAR_ORIG_COMMIT_REV_ID: 5204d8180f7dfe4ede4afc7392e7c61d603aaa4d
[External] [stdlib] Fix `Roundable` example

I left the `Absable` one (even though it's broken), since it will
probably change with associated aliases.

Co-authored-by: Helehex <[email protected]>
Closes modular#3685
MODULAR_ORIG_COMMIT_REV_ID: 686a53086cecc5201a40964de05caf973b65b07a
This is to enable buffering before printing output, where some state
needs to be held, which wasn't possible when passing a closure for the
write function to a `Formatter`. The next PR in stack improves the print
performance by 122x on a 10k loop of 5 args, coming within 1ms of C, and
2.27x faster than Python.

MODULAR_ORIG_COMMIT_REV_ID: 00dc54c9e57a3343c3d74a7432db2762a2badc1b
Change `format_sequence` to align with naming of other methods
and traits, can now use `write` to construct a type, or write into
an existing one.

MODULAR_ORIG_COMMIT_REV_ID: bdba2af6155f806c5cd28fd0514d0b02a8d7b784
- Replacing `_strref_dangerous` with `as_string_slice`.
- Replacing `StringRef` overloads in String with `StringSlice`.
- Enabled `StringSlice` to support the `Hashable` trait.
-  `StringSlice` implements less-than comparable.
- `StringSlice` implements `__getitem__` enabling subscript expression
support.
- Implement the following `StringSlice` functions: strip, startswith,
endswith, find, and find.

MODULAR_ORIG_COMMIT_REV_ID: 80fc97fe0b5efe3ccb9183426084f1491ed2c9f6
MODULAR_ORIG_COMMIT_REV_ID: f7cd7f188de7424f9afde75a8df611008ff7c873
[External] [docs] Fix docstring examples in `Variant`.

Since `Variant.__getitem__()` uses auto-deref now.

Co-authored-by: Helehex <[email protected]>
Closes modular#3689
MODULAR_ORIG_COMMIT_REV_ID: 9bd494c759d5639b0ee16dc092d627867f8e843e
MODULAR_ORIG_COMMIT_REV_ID: 668c77a6b9c949e1072749f8d51ed0aa6c07136b
This greatly improves the print performance, minimizing syscalls and
multiple variadic pack loads. These are results from printing 5 args in
a 10k loop on the fast alacritty terminal emulator:

```
Program         : Average  : Slowdown
C clang -O3     : 110ms    : 1.00x
rust release    : 122ms    : 1.11x
go 1.23         : 125ms    : 1.14x
python 3.12     : 250ms    : 2.27x
mojo current    : 13.44s   : 122.18x
mojo buffered   : 111ms    : 1.01x
```

Also improves writing to file speed by 500x on a 10k loop with 5 args,
from 9.85s to 20ms.

And moves sep and end formatting to a `write_args` function to reuse it.

MODULAR_ORIG_COMMIT_REV_ID: 0e6d526042eb66ec5e16104e858b81095b4b2980
MODULAR_ORIG_COMMIT_REV_ID: 74cfb5f0e9368b5b1cfd9b3a30723edbd7ccccac
Our debugger now supports data breakpoints and function breakpoints, so
let's update the docs.

MODULAR_ORIG_COMMIT_REV_ID: c3c54f8c955974c74f7f8b5ffdda5e64bc9d4dbe
Adds a changelog entry for `Writer` and `Writable`, with an
example of how to use the changes.

MODULAR_ORIG_COMMIT_REV_ID: 80009738091cb8191dd8e8bc985cbeb3d7703dd5
MODULAR_ORIG_COMMIT_REV_ID: d77d88e20ea8c940c6e186333431f05a65de2760
MODULAR_ORIG_COMMIT_REV_ID: 38d50dea7fe848ca527e8a984e165c3553ec7c5d
[External] [stdlib] Fix `string_slice.mojo` docstrings

Fix `string_slice.mojo` docstrings

ORIGINAL_AUTHOR=martinvuyk
<[email protected]>
PUBLIC_PR_LINK=modular#3699

Co-authored-by: martinvuyk <[email protected]>
Closes modular#3699
MODULAR_ORIG_COMMIT_REV_ID: 99638231ea74213a63c95e17560a9276cf16c09e
Refactoring the `String.__eq__` code to remove uses of
`_strref_dangerous`.

MODULAR_ORIG_COMMIT_REV_ID: 7bfbfed01df3a1140763f828ae5f7004815d6025
Update documentation to provide more context than the word "superset"
can communicate alone.

Was: Our vision is for Mojo to become a superset of Python.

Now, depending on context:
- Our vision is for Mojo to become the best way to extend Python.
- Our intent is for Mojo to adopt the syntax of Python.

MODULAR_ORIG_COMMIT_REV_ID: 8a9a6f3135fd333578b792cb5b82f76b32aaeb76
…benchmarks (#49095)

[External] [stdlib] Add string benchmarking infrastructure and basic
benchmarks

Add string benchmarking infrastructure and basic benchmarks.

Added data for benchmarking collections.

UN charter:
Taken from the official [UN
website](https://www.un.org/en/about-us/un-charter/full-text) with the
language abbreviations following ISO 639-1 except simplified mandarin
chinese (zh-CN)

ORIGINAL_AUTHOR=martinvuyk
<[email protected]>
PUBLIC_PR_LINK=modular#3523

Co-authored-by: martinvuyk <[email protected]>
Closes modular#3523
MODULAR_ORIG_COMMIT_REV_ID: d3b154bc993eccf4b80bb3773895bc28e1f41ee6
'_cpython.mojo'

Removing `String._strref_dangerous` from `python_object` and from the
`_cpython.mojo` implementation.

MODULAR_ORIG_COMMIT_REV_ID: 86ce43868974118d0ea18be90e0a5abbc240d58d
[External] [stdlib] Fix docstring examples in `Dict`

Co-authored-by: Helehex <[email protected]>
Closes modular#3688
MODULAR_ORIG_COMMIT_REV_ID: ca648f169c31242b3aced62a798490914fbbc6e4
MODULAR_ORIG_COMMIT_REV_ID: 0c5d82026a82f674ce0d1a72e8322265ee646ce9
MODULAR_ORIG_COMMIT_REV_ID: e372890116ec45b133713100d510f59c9eb31710
graph.

These are some of the final changes before we can remove the
'String._strref_dangerous' function completely from the code base.

MODULAR_ORIG_COMMIT_REV_ID: 7a82694f203b98a4919599a0c61e89de7b86d544
Remove a TODO and some extraneous `_ = <...>` patterns. While in the
neighborhood, mark `CPython` with `@value` decorator since the copyinit
is the same as the one that the compiler would generate.

MODULAR_ORIG_COMMIT_REV_ID: 808b19875d62a9bf9679a2122434eba26b3ee369
Now that the `math` module is open-source, move the contents of
`builtin/_math.mojo` into `math/math.mojo`. Explicitly re-export
`Truncable` from `math/__init__.mojo`.

In a follow-up, we should be able to consolidate `builtin/math.mojo`
into `math/math.mojo` and just re-export the necessary entities now that
we have a a `prelude` module.

MODULAR_ORIG_COMMIT_REV_ID: 56ddc5b0e33490532b3908a9eeb1dd2c01d13b33
Fixes MOTO-821

This is an internal function and shouldn't appear in https://docs.modular.com/mojo/stdlib/builtin/error/

MODULAR_ORIG_COMMIT_REV_ID: a3fd1c63e437308cad2316c20f2b4320410892c9
abduld and others added 22 commits December 17, 2024 16:33
MODULAR_ORIG_COMMIT_REV_ID: 78e0005db0bb77465e11d6ce856da56116c839dc
This adds support for spelling "named functions results" using the same
`out`
syntax used by initializers (in addition to `-> T as name`). Functions
may have
at most one named result or return type specified with the usual `->`
syntax.
`out` arguments may occur anywhere in the argument list, but are
typically last
(except for `__init__` methods, where they are typically first).

```mojo
  # This function has type "fn() -> String"
  fn example(out result: String):
    result = "foo"
```

The parser still accepts the old syntax as a synonym for this, but that
will
eventually be deprecated and removed.

This was discussed extensively here:
modular#3623

MODULAR_ORIG_COMMIT_REV_ID: 23b3a120227a42d9550ba76d8cafb63c3a03edcf
Updates for the new default explicit constructors & `@implicit`
decorator.

MODULAR_ORIG_COMMIT_REV_ID: ef4ab402b9e2c63747f26f7ab4e6e3208859a8d7
MODULAR_ORIG_COMMIT_REV_ID: ae0b65162253dd2e39cf820d2be615f4678da830
MODULAR_ORIG_COMMIT_REV_ID: 0d3fca509ce444c56e0cb65814e2696150e86b18
This just tidies up some code to avoid using patterns that will soon be
invalid: as the 'out' argument on inits is becoming more normal, you
won't be able to pass a value in at a call site, it is always a result.
MODULAR_ORIG_COMMIT_REV_ID: b9e5685612246c8c758b4191f3a70f61a4eecff5
If the elements are hinted as "trivial", skip running the destructors
for them. Note that we don't have a checked equivalent of
`std::is_trivially_destructible`, so this is just relying on the hint
provided to `List`. For non-trivial types, we still run the destructors
on each of the elements, of course.

Future PRs will take advantage of the `hint` parameter in `copyinit`.

MODULAR_ORIG_COMMIT_REV_ID: c92f98b69f1a40b7b671b6392a7b71b54cfb61b8
…` (#52307)

[External] [stdlib] Micro-optimize string `splitlines` and `isnewline`

## Micro-optimize string `splitlines` and `isnewline`.

Benchmark results:

CPU: Intel® Core™ i7-7700HQ

improvement metric: markdown percentage improvement (`(old_value -
new_value) / old_value`)

Average improvement: 1.2% . Many of the discrepancies are likely because
of runtime (nano-second scale) pipelining (and other) differences during
testing. The most robust estimates are the biggest tests which show
around 4.2% improvement.

|Name | old_value (ms) | new_value (ms) | improvement|

|:-----------------------------|---------------------:|----------------:|------:|
|`bench_string_splitlines[10]` | 0.000100497059839818 | 0.00010261460376
| -2.11% |
|`bench_string_splitlines[30]` | 0.000171998352418428 |
0.000174028055158599 | -1.18% |
|`bench_string_splitlines[50]` | 0.000264958575880379 |
0.000251598931395228 | 5.04% |
|`bench_string_splitlines[100]` | 0.000417350538881514 |
0.000415764808815687 | 0.38% |
|`bench_string_splitlines[1000]` | 0.00320600819966129 |
0.00322517645847026 | -0.60% |
|`bench_string_splitlines[10000]` | 0.0302790238107332 |
0.0305872863513719 | -1.02% |
|`bench_string_splitlines[100000]` | 0.319274428592796 |
0.304513179279761 | 4.62% |
|`bench_string_splitlines[1000000]` | 3.24098357344348 |
3.10220707742267 | 4.28% |

Co-authored-by: martinvuyk <[email protected]>
Closes modular#3825
MODULAR_ORIG_COMMIT_REV_ID: 433b5ea2f49164bf08572004da1541ac42f1eed2
[External] [stdlib] Snake casing stdlib

Convert camelCase code to a pythonic snake_case throughout the stdlib

Co-authored-by: Manuel Saelices <[email protected]>
Closes modular#3631
MODULAR_ORIG_COMMIT_REV_ID: f308889bd1a2221371fa2b2d85ea2f30da333667
…s (#52407)

[External] [docs] Prevent unwanted Latex interpretation in `Path` docs

As title, see [docs](https://docs.modular.com/mojo/stdlib/pathlib/path/Path#home).

Co-authored-by: Joshua James Venter <[email protected]>
Closes modular#3844
MODULAR_ORIG_COMMIT_REV_ID: d3cc7796c2b2fc8991bd958984c0d2313a9bfcd5
The tutorial gives new Mojo programmers a tour of some of the language's
features by guiding them through the process of creating an
implementation of Conway's Game of Life from scratch.

MODULAR_ORIG_COMMIT_REV_ID: 3548d7d23c6f612ef22b730106646b8332ce8dfa
`in` and `is` operators with `PythonObject` values.

MODULAR_ORIG_COMMIT_REV_ID: 4f58b6a25ba4138a25fddf691e7aaaf1fb333d02
MODULAR_ORIG_COMMIT_REV_ID: 9e019cdabf2bd6d46df078522f1633df94388920
MODULAR_ORIG_COMMIT_REV_ID: 20fb09bc7db26baf4f6f30bef9d67037b41fdec2
MODULAR_ORIG_COMMIT_REV_ID: 1d176b9be734cfcaef30f4da54bb748ccb0e1106
changes

MODULAR_ORIG_COMMIT_REV_ID: d87d1ea4e81ffc5625accbab753d23ef0fd03c9a
Replace curly quotes/apostrophes (') with straight ones (') throughout
developer documentation for consistency.

MODULAR_ORIG_COMMIT_REV_ID: 34216041b3d7d74bf5e5621997c3d1becd6f7360
MODULAR_ORIG_COMMIT_REV_ID: ab3b585f293c179b2b61963064c5f4402a96a4df
MODULAR_ORIG_COMMIT_REV_ID: 8e3e29b7f9379523b8b25c73315b8d09a020a996
@rcghpge rcghpge changed the base branch from main to nightly January 23, 2025 11:18
@rcghpge rcghpge requested a review from jackos as a code owner January 23, 2025 11:18
@rcghpge
Copy link
Author

rcghpge commented Jan 23, 2025

Hey Mojo team. It looks like failing checks with the MacOS pipeline. I updated my machine locally for Magic with magic update and magic upgrade. Other than that and the typo. The checks look like something about version 6 on my end but will only pass version 5.

update - hmm looks like it is with the stdlib alone 🤔

@JoeLoser JoeLoser requested a review from arthurevans January 27, 2025 17:19
@arthurevans
Copy link
Collaborator

It looks like this PR might be based on main but targeted to nightly, so there's a lot of extraneous commits in here.

Can you either re-do your PR starting from nightly, or cherry-pick your commit on top of a branch based on nightly, which ever seems easier? Thanks!

@rcghpge
Copy link
Author

rcghpge commented Jan 27, 2025

Hey Evan, I’ll look it over when I can. I switched to nightly vs the main stable branch. main is stable mainline Mojo if I am looking at this correctly? Is main development fairly dialed back compared to nightly? Talk soon.

@rcghpge
Copy link
Author

rcghpge commented Jan 27, 2025

I’ve thought it over for a bit. I’ll pull the latest from mainline nightly and main and go over the codebase. I’ll close out the PR because there are too many chained commits and file the minor typo issue if it can be updated from there. I should or need to be sure I have the most up to date on mainline branches 👍

@rcghpge rcghpge closed this Jan 27, 2025
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.