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

  • Home
  • SEARCH
  • 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 183771
In Process

The Archive Base Latest Questions

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

Many methods that used to return lists in Python 2.x now seem to return

  • 0

Many methods that used to return lists in Python 2.x now seem to return iterators in Py3k

Are iterators also generator expressions? Lazy evaluation?

Thus, with this the memory footprint of python is going to reduce drastically. Isn’t it?

What about for the programs converted from 2to3 using the builtin script?

Does the builtin tool explicitly convert all the returned iterators into lists, for compatibility? If so then the lower memory footprint benefit of Py3k is not really apparent in the converted programs. Is it?

  • 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. 2026-05-11T15:10:30+00:00Added an answer on May 11, 2026 at 3:10 pm

    Many of them are not exactly iterators, but special view objects. For instance range() now returns something similar to the old xrange object – it can still be indexed, but lazily constructs the integers as needed.

    Similarly dict.keys() gives a dict_keys object implementing a view on the dict, rather than creating a new list with a copy of the keys.

    How this affects memory footprints probably depends on the program. Certainly there’s more of an emphasis towards using iterators unless you really need lists, whereas using lists was generally the default case in python2. That will cause the average program to probably be more memory efficient. Cases where there are really big savings are probably going to already be implemented as iterators in python2 programs however, as really large memory usage will stand out, and is more likely to be already addressed. (eg. the file iterator is already much more memory efficient than the older file.readlines() method)

    Converting is done by the 2to3 tool, and will generally convert things like range() to iterators where it can safely determine a real list isn’t needed, so code like:

    for x in range(10): print x 

    will switch to the new range() object, no longer creating a list, and so will obtain the reduced memory benefit, but code like:

    x = range(20) 

    will be converted as:

    x = list(range(20)) 

    as the converter can’t know if the code expects a real list object in x.

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

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You forgot to specify/pass $page and $sitemap. Where do that… May 12, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer This command will cause the current session of screen to… May 12, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer A RegExp object with the g flag keeps track of… May 12, 2026 at 3:51 pm

Related Questions

What is the most elegant way to implement this function: ArrayList generatePrimes(int n) This
The first thing I do in a public method is to validate every single
I'm maintaining a script that can get its input from various sources, and works
I'm doing research into a web API for my company, and it's starting to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.