Skip to content

Commit 871045c

Browse files
martinvuykJoeLoser
authored andcommitted
[External] [stdlib] [NFC] Rename List.bytecount() to byte_length() (#54664)
[External] [stdlib] [NFC] Rename `List.bytecount()` to `byte_length()` Rename `List.bytecount()` to `byte_length()` to keep consistency with all Stringlike types. Co-authored-by: martinvuyk <[email protected]> Co-authored-by: Joe Loser <[email protected]> Closes #3897 MODULAR_ORIG_COMMIT_REV_ID: bcb5da166f0490eaea10f88a45cf9023e8bb8f63
1 parent c53dc5a commit 871045c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

docs/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ ctx.enqueue_function(compiled_func, grid_dim=1, block_dim=1)
132132
var val1 = warp.broadcast(x)
133133
```
134134

135+
- `List.bytecount()` has been renamed to `List.byte_length()` for consistency
136+
with the String-like APIs.
137+
135138
### Tooling changes
136139

137140
#### Mojo Compiler

stdlib/src/collections/list.mojo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,11 @@ struct List[T: CollectionElement, hint_trivial_type: Bool = False](
467467
# Methods
468468
# ===-------------------------------------------------------------------===#
469469

470-
fn bytecount(self) -> Int:
471-
"""Gets the bytecount of the List.
470+
fn byte_length(self) -> Int:
471+
"""Gets the byte length of the List (`len(self) * sizeof[T]()`).
472472
473473
Returns:
474-
The bytecount of the List.
474+
The byte length of the List (`len(self) * sizeof[T]()`).
475475
"""
476476
return len(self) * sizeof[T]()
477477

stdlib/test/collections/test_list.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_list():
4545
list.append(i)
4646

4747
assert_equal(5, len(list))
48-
assert_equal(5 * sizeof[Int](), list.bytecount())
48+
assert_equal(5 * sizeof[Int](), list.byte_length())
4949
assert_equal(0, list[0])
5050
assert_equal(1, list[1])
5151
assert_equal(2, list[2])

0 commit comments

Comments
 (0)