GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — factory func of collections.defaultdict should receive the "missing key" as args when called. · Issue #56682 · python/cpython

factory func of collections.defaultdict should receive the "missing key" as args when called. #56682

New issue
Copy link
New issue
Copy link
Closed
Closed
factory func of collections.defaultdict should receive the "missing key" as args when called.#56682
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

lyricconch
mannequin
opened on Jul 2, 2011
Issue body actions
BPO 12473
Nosy @amauryfa

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-07-02.08:31:11.474>
created_at = <Date 2011-07-02.07:21:09.476>
labels = ['invalid', 'type-bug', 'library']
title = 'factory func of collections.defaultdict should receive the "missing key" as args when called.'
updated_at = <Date 2011-07-02.08:31:11.467>
user = 'https://bugs.python.org/lyricconch'

bugs.python.org fields:

activity = <Date 2011-07-02.08:31:11.467>
actor = 'amaury.forgeotdarc'
assignee = 'none'
closed = True
closed_date = <Date 2011-07-02.08:31:11.474>
closer = 'amaury.forgeotdarc'
components = ['Library (Lib)']
creation = <Date 2011-07-02.07:21:09.476>
creator = 'lyricconch'
dependencies = []
files = []
hgrepos = []
issue_num = 12473
keywords = []
message_count = 2.0
messages = ['139624', '139625']
nosy_count = 2.0
nosy_names = ['amaury.forgeotdarc', 'lyricconch']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue12473'
versions = ['Python 2.7']

Activity

  1. lyricconch commented on Jul 2, 2011

    @lyricconch
    lyricconchmannequin
    on Jul 2, 2011
    MannequinAuthor
    More actions
    for example:
    
    def calc(params):
        """ i am factoring numbers. """
        # an expensive CPU cost function but 
        # passin params and return result are both lightweight
    
    cachedcalc = collections.defaultdict(calc)
    result = cachedcalc[0xFFFFFFFFFFFFFFFFFFF0AC0FFF1]
  2. lyricconch
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 2, 2011
  3. amauryfa commented on Jul 2, 2011

    @amauryfa
    amauryfa
    on Jul 2, 2011
    Contributor
    More actions

    -1. Besides compatibility issues, defaultdict is a dict: it contains data, and is not meant to consume CPU when accessing items. Its "default" function should return initial values, like 0 or an empty list.

    I think what you want is "memoization"; a memoized function still looks like a function! there are many implementations for python, one of these is here: http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize

  4. amauryfa
    closed this as completedon Jul 2, 2011
  5. amauryfa
    added
    invalid
    on Jul 2, 2011
  6. ezio-melotti
    transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.