Created
December 26, 2023 23:16
-
-
Save btimby/b05036d06bc95e88c4add6fd248b9e7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> one_gig = 1024*1024*1024 | |
>>> thirty_two_gigs = one_gig * 32 | |
>>> one_gig * 32 == thirty_two_gigs | |
True | |
>>> for i in range(thirty_two_gigs): | |
... _ = f.write("\n") | |
... if i % one_gig == 0: print(i) | |
... | |
0 | |
1073741824 | |
2147483648 | |
3221225472 | |
4294967296 | |
5368709120 | |
6442450944 | |
7516192768 | |
8589934592 | |
9663676416 | |
10737418240 | |
11811160064 | |
12884901888 | |
13958643712 | |
15032385536 | |
16106127360 | |
17179869184 | |
18253611008 | |
19327352832 | |
20401094656 | |
21474836480 | |
22548578304 | |
23622320128 | |
24696061952 | |
25769803776 | |
26843545600 | |
27917287424 | |
28991029248 | |
30064771072 | |
31138512896 | |
32212254720 | |
33285996544 | |
>>> for _ in range(1024): | |
... _ = f.write("A") | |
... | |
>>> f = open("/dev/sda", "r") | |
>>> for i in range(thirty_two_gigs): | |
... if f.read(1) == "A": print(i, "A") | |
... if i % one_gig == 0: print(i) | |
... | |
0 | |
1073741824 | |
2147483648 | |
3221225472 | |
4294967296 | |
5368709120 | |
6442450944 | |
7516192768 | |
8589934592 | |
9663676416 | |
10737418240 | |
11811160064 | |
12884901888 | |
13958643712 | |
15032385536 | |
16106127360 | |
17179869184 | |
18253611008 | |
19327352832 | |
20401094656 | |
21474836480 | |
22548578304 | |
23622320128 | |
24696061952 | |
25769803776 | |
26843545600 | |
27917287424 | |
28991029248 | |
30064771072 | |
31138512896 | |
32212254720 | |
33285996544 | |
>>> for i in range(thirty_two_gigs): | |
... if f.read(1) == "A": print(i, "A") | |
... if i % one_gig == 0: print(i) | |
... | |
0 | |
1073741824 | |
2147483648 | |
3221225472 | |
^CTraceback (most recent call last): | |
File "<stdin>", line 2, in <module> | |
KeyboardInterrupt | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First write 32GB of newlines, then 1KB of "A" chars. Read back 32G, then read back 3G more and note that "A" is not found.