Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7569589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:12:14+00:00 2026-05-30T15:12:14+00:00

If a pre-compiled property is a property that is calculated and cached on the

  • 0

If a pre-compiled property is a property that is calculated and cached on the first access; I’d like to do the same but, instead, take multiple lists and compile them to one master list.

For a little background, I’m currently building a site GAE/python/webapp2/jinja2. Sparing the nitty-gritty, my list of routes is growing pretty large. Currently, I have static routes, dynamic routes, and redirects all mashed up into one list.

Example:

master = [
  Route('/',StaticHandler, defaults={'_uri':'index.html'}),
  Route('/about-us', StaticHandler, defaults={'_uri':'index.html'})
  Route('/secure/', AuthHandler, defaults={'_uri':'secure.html'}),
  Route('/secure/<_uri>', AuthHandler, defaults={'_uri':'not-found.html'})
  Route('/about.html', RedirectHandler, defaults={'_uri':'about-us'})]

To keep things simple, I’d like to group them like:

main = [
  Route('/',StaticHandler, defaults={'_uri':'index.html'}),
  Route('/about-us', StaticHandler, defaults={'_uri':'index.html'})]

auth = [
  Route('/secure/', AuthHandler, defaults={'_uri':'secure.html'}),
  Route('/secure/<_uri>', AuthHandler, defaults={'_uri':'not-found.html'})]

redirect = [
  Route('/about.html', RedirectHandler, defaults={'_uri':'about-us'})]

Currently I’m using:

master = main + auth + redirects

Which works but I’m thinking that I need to wrap this in a class property to make it cacheable.

So far, I have tried:

class master(object):
  def __init__(self):
    self.list = list(set(main) & set(auth) & set(redirects))
  def __iter__(self):
    return iter(self.list)

But I get the error, “TypeError: ‘type’ object is not iterable”.

So I need 2 things:

  1. A way to wrap the combined list as a class property
  2. A way to make the property cacheable (preferrably as a decorator)

What I don’t want to deal with is the added overhead incurred by doing a list compilation on every call.

I have read about and used a cached property decorator but I’m not really clear on how they work and/or if they could be easily adapted to work with lists.

Note: Although contrived, the example here is meant to keep things simple. The long term goal here is be to provide 2 different sets of routes depending on the app configuration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:12:15+00:00Added an answer on May 30, 2026 at 3:12 pm

    Your starting presumption, that the routes list is calculated on every request, is wrong. These are defined at the module level, so will be calculated the first time they are imported which is when each instance starts up. Pre-compiling or memoizing would just do exactly the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pre-compiled headers seem like they can save a lot of time in large projects,
I just finished a small project where changes were required to a pre-compiled, but
I have a .NET assembly DLL that is created on-the-fly from pre-compiled code in
Can you mix .net languages within a single project? So pre-compiled, I would like
After pre-compiled a ASP.NET web site, I got many files with the names like
I am using pre-compiled headers in my project in C but we are integrating
I often heard people saying that stored procedures are pre-compiled. What does it mean?
In a pre-compiled header if I do: #define DS_BUILD #define PGE_BUILD #define DEMO then
I wonder how a can include an pre-compiled binary in an iPhone application. I
Has anyone compiled, or know of a pre-compiled, libnoise for MacOS X 10.6? It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.