-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[Feature Request] Add path.getsize or file.getsize methods #1130
Comments
I like this idea, but how about divide words via "_"? In my opinion get_size looks much better than getsize |
Proper naming is really tricky for the language that supposed to be a "drop-in replacement for Python" . Let's see how it feels in other languages : Cpp
Zig
Julia
Python
Swift
I think the Python version is most expected variation (for Python switchers at least) |
Thanks @tairov for requesting this (in the the live stream of all places :) ) . We'll make sure this is prioritized. Keep up the great work |
If you use tools which will give you code completion, you will obtain both get_size and getsize, so I don't think that is the case here. Readability counts and it is greater with seperated words than mixed up (see simdbitwidth, simdwithof and so on |
Also, most functions in Mojo have divided words, so every case which breaks from that looks strange |
I hope till stable release the Mojo team will stabilize API & naming conventions.. In other case it could end-up "PHP" scenario. The names of the functions laid down in the first releases have already turned out to be extremely difficult to isolate from the language, and as a result, the entire standard library of functions has become quite heterogeneous. This problem was solved only with the introduction of high-level frameworks (like Laravel & Symfony) that abstracted methods from the standard PHP library and made framework API more clean. I'm honestly really not sure about proper approach here.. I would suggest to make the API more closer to Python, since it might help with Python -> Mojo switch & learning curve. As you mentioned, if we use code-completion tools it doesn't make much difference I believe. Especially taking into account the long-term goals of creating a coherent language and further adaptation to it by the community.. Probably by that time you won’t have to read the code, everything will be explained to you by the LLM/AI agent 😀 |
Thanks @abduld for your feedback.. BTW, I decided to vectorize "feature requests", so a small cart there, a couple more requests #1134 & #1135 😅 PS. It was a great honor to share the livestream stage with your team! |
Yeah, stable and standardized naming convention would be a great benefit over Python which Mojo tends to be a better version (Python++). This also mean, that Mojo could fix these Python problems related to naming. Mojo should take the best from Python and fix what may be improved. I will vote for being consistent with own rules and not to break them when trying to replicate Python. As far as I know this strict replication is not possible, so sticking with exactly same names as Python has, is not the best idea IMHO. Please to be consistent first of all, even if this will require to take other name than Python has. Edit: one of the big problem related to keeping the same names as Python has is the need of synchronisation with its changes. Let's suppose, that Mojo will take all the names which Python has in some library. If Python will decide to deprecate some function and propose another one instead, Mojo, following changes, should also deprecate this method in its stdlib. Keeping everything in sync would led to maintenance hell. |
[External] [stdlib] Implement `os.path.getsize` Add `getsize` method for getting the size (in bytes) of a path. Fixes #1130 ORIGINAL_AUTHOR=artemiogr97 <57588855+artemiogr97@users.noreply.github.com> PUBLIC_PR_LINK=#2626 Co-authored-by: artemiogr97 <57588855+artemiogr97@users.noreply.github.com> Closes #2626 MODULAR_ORIG_COMMIT_REV_ID: 443260f3be31a694c9e93fc11b64d0317646c4e0
[External] [stdlib] Implement `os.path.getsize` Add `getsize` method for getting the size (in bytes) of a path. Fixes modularml#1130 ORIGINAL_AUTHOR=artemiogr97 <57588855+artemiogr97@users.noreply.github.com> PUBLIC_PR_LINK=modularml#2626 Co-authored-by: artemiogr97 <57588855+artemiogr97@users.noreply.github.com> Closes modularml#2626 MODULAR_ORIG_COMMIT_REV_ID: 443260f3be31a694c9e93fc11b64d0317646c4e0
[External] [stdlib] Implement `os.path.getsize` Add `getsize` method for getting the size (in bytes) of a path. Fixes #1130 ORIGINAL_AUTHOR=artemiogr97 <57588855+artemiogr97@users.noreply.github.com> PUBLIC_PR_LINK=#2626 Co-authored-by: artemiogr97 <57588855+artemiogr97@users.noreply.github.com> Closes #2626 MODULAR_ORIG_COMMIT_REV_ID: 443260f3be31a694c9e93fc11b64d0317646c4e0
Review Mojo's priorities
What is your request?
Mojo v0.4.0 now supports
file
module, but it seems that we still need one essential function --getsize
orfilesize
With native Mojo
file
module we have to load whole file into memory just to know its size.What is your motivation for this change?
So far in
llama2.🔥
we have to use workaround via Python.It's turned out newcomers to Mojo who are trying to run llama2 locally, got multiple issues because of misconfiguration with
MOJO_PYTHON_LIBRARY
, etc.It would be great to add
getsize
orfilesize
tofile
orpath
modules in the next release.Any other details?
In Python it's implemented in
path
moduleI think it's worthwhile to implement the more general
os.stat
, sincefs_stat
must provide more details about file, but I'm not sure what are the concerns regarding platforms compatiblity.The text was updated successfully, but these errors were encountered: