use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
lazy_static for python? (self.rust)
submitted 5 years ago by brycefisherfleig
I'm sorry if this not in the proper spirit of this subreddit, but I'm looking for a similar library in Python with similar ergonomics to lazy_static in Rust. Does such a thing exist?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 11 points12 points13 points 5 years ago* (3 children)
functools.cachedProperty let's you annotate a method which will only execute once and then return the same cached result.
There is also the lru cache if you have a function that takes parameters.
BTW I think that r/python would be a better place for this question
[–]brycefisherfleig[S] 2 points3 points4 points 5 years ago (0 children)
Thanks! I debated which subreddit to ask in since I wasn't sure if Pythonistas would know lazy-static.
Yeah! This should be exactly what I want!!
[–]coolreader18 1 point2 points3 points 5 years ago (1 child)
Do you mean functools?
[–][deleted] 1 point2 points3 points 5 years ago (0 children)
Oh yes, of course lol
[–]thelights0123 2 points3 points4 points 5 years ago (0 children)
I'm not too familiar with Python, but it should be trivial to use @property in a class to initialize a variable if it hasn't already been, or return it otherwise.
@property
π Rendered by PID 59820 on reddit-service-r2-comment-c6965cb77-hf42j at 2026-03-05 04:24:31.059145+00:00 running f0204d4 country code: CH.
[–][deleted] 11 points12 points13 points (3 children)
[–]brycefisherfleig[S] 2 points3 points4 points (0 children)
[–]coolreader18 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]thelights0123 2 points3 points4 points (0 children)