-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is relevant particularly to precompilation, which requires that any module global dicts get rehashed by the __init__ function.
- Loading branch information
Showing
2 changed files
with
3 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that
rehash
is not yet exported (or documented).e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably also have
rehash
forObjectIdDict
.e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it shouldn't be exported.
e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not, if you think this is useful for external packages that want to be precompiled?
e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, ObjectIdDicts don't need to be rehashed when used in precompiled code (see #8665).
e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good to know.
e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
rehash!
since it is mutating, BTW?e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably true. But in the same vein, should
sizehint
really besizehint!
? In neither case is the content of the container being mutated, it's only something about the internal representation.e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer
sizehint
to besizehint!
. :-)e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that @JeffBezanson has some strongish opinions about this.
e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to consider something "mutating" only if it changes what values the argument would be
==
to. However I suppose there is another view, which says a function is mutating if you don't need its return value to get its effect. For example a non-mutatingsizehint
would look likeSafe to say nobody will be asking for such a function.
Another way to look at it is the "permissions" view: if
f
were not allowed to mutatex
, would it be ok forf
to callsizehint
orrehash
?Then there is the "concurrency" perspective: these functions write to the values, so even if there is no net effect it is not safe to do concurrently with other operations on the values.
So I'm not sure; this is a borderline case!
e7ce4cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having spent a bunch of time talking about Rust lately, I'd like Julia to adopt the concurrency/write viewpoint when deciding whether to use exclamation marks.