Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Caching with key func #61

Closed
wants to merge 3 commits into from
Closed

Caching with key func #61

wants to merge 3 commits into from

Conversation

koreno
Copy link
Contributor

@koreno koreno commented Feb 16, 2018

No description provided.

# Signature.bind_partial().
continue
new_arguments.append((name, val))
bound_arguments.arguments = OrderedDict(new_arguments)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why convert a list of pairs to an OrderedDict? Why not just make an empty OrderedDict and populate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the code from python3.5 sources, didn't want to change anything to official code.

bound_arguments.arguments = OrderedDict(new_arguments)
else:
def _apply_defaults(bound_arguments):
return bound_arguments.apply_defaults()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bound_arguments.apply_defaults() returns None, but it's still weird that this version "returns" something while the backward-compatibility version doesn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm like a decorator, don't care about implementation detail, I want to be future-compatible.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future-compatibility-wise, if in the future apply_default will return something, someone might use the value returned from _apply_defaults believing it's backward compatible

assert d[AUTO] == AUTO
assert d[MAX] == MAX
assert d['<MAX>'] is MAX
assert 'AUTO' not in d

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait what? Isn't this a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll revisit this at some point...

@koreno
Copy link
Contributor Author

koreno commented Mar 3, 2018

(already merged)

@koreno koreno closed this Mar 3, 2018
@YuvalEvron YuvalEvron deleted the caching-with-key_func branch August 6, 2019 08:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants