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 7172961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:43:28+00:00 2026-05-28T15:43:28+00:00

Im curious to know how lazy evaluation is implemented at higher levels, ie in

  • 0

Im curious to know how lazy evaluation is implemented at higher levels, ie in libraries, etc. For example, how does the Django ORM or ActiveRecord defer evaluation of query until it is actually used?

  • 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-28T15:43:29+00:00Added an answer on May 28, 2026 at 3:43 pm

    Let’s have a look at some methods for django’s django.db.models.query.QuerySet class:

    class QuerySet(object):
        """
        Represents a lazy database lookup for a set of objects.
        """
        def __init__(self, model=None, query=None, using=None):
            ...
            self._result_cache = None
            ...
    
         def __len__(self):
            if self._result_cache is None:
              ...
            elif self._iter:
              ...
            return len(self._result_cache)
    
        def __iter__(self):
            if self._result_cache is None:
              ...
            if self._iter:
              ...
            return iter(self._result_cache)
    
        def __nonzero__(self):
            if self._result_cache is not None:
              ...
    
        def __contains__(self, val):
            if self._result_cache is not None:
              ...
            else:
              ...
            ...
    
        def __getitem__(self, k):
            ...
            if self._result_cache is not None:
            ...
            ...
    

    The pattern that these methods follow is that no queries are executed until some method that really needs to return some result is called. At that point, the result is stored in self._result_cache and any subsequent call to the same method returns the cached value.

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

Sidebar

Related Questions

I'm curious to know how the passwords in linux are maintained in /etc/shadow. Even
I am curious to know why this is happening. Please read the code example
I am curious to know how does paging work in asp.net? If my query
I'm curious to know: is scrolling (such as in Firefox, Nautilus, etc.) handled be
I know brief about hadoop I am curious to know how does it work.
Just curious to know, Test module won't work properly with django 1.2.3 when update
I curious to know how the jQuery.load functionality affects page load speeds when reporting
I'm curious to know why the C# compiler only gives me an error message
I'm curious to know if multiple images actually show up in the feed. I
I'm curious to know what happens if I set the parameter count in cudaMemcpyAsync

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.