Skip to content

Conversation

@BCSharp
Copy link
Member

@BCSharp BCSharp commented Apr 23, 2025

This PR builds further on #1721 and #1946 (issue #1718) by using CodeContext with various iterables.

}

public static object? CallWithArgsTuple(object func, object?[] args, object argsTuple) {
public static object? CallWithArgsTuple(object func, object?[] args, IEnumerable argsTuple) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the goal with the signature change is to get rid of the context-less PythonOps.GetEnumerator call? Maybe adding the CodeContext argument would be "better"? Although looking at usage this function is basically useless and is a good candidate for removing/obsoleting...

Copy link
Member Author

Choose a reason for hiding this comment

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

The goal was to get rid of the call to PythonOps.GetEnumerator here altogether. Arguably, a call with the context is "better" (in most cases but not all) than the context-less call, but in both cases it goes though PythonContext.TryConvertToIEnumerable, which unnecessarily "pollutes" the call site cache. It just caught my attention while reviewing the usage of PythonOps.GetEnumerator in the codebase.

The signature has changed to a more restrictive one, indeed, but looking at the usage and the name of of the method, one can assume that the type of parameter argsTuple is supposed to be a tuple… Indeed, originally I have changed the type to PythonTuple here, but since it is a public method, I thought that having IEnumerable will be less of an inconvenience for the user code that happens to use this method. For a while I also considered of typing it as ITuple, but (1) it would require adding this interface to PythonTuple (perhaps not a bad idea anyway for other reasons) and (2) no code in the wild makes calls to this method with Tuple because it is not enumerable, so why bother.

I have no opinion about obsolescence of this method; if you think it is worthwhile removing then go ahead!

@slozier slozier merged commit 71a8f5c into IronLanguages:main Apr 25, 2025
17 checks passed
@BCSharp BCSharp deleted the iterable_context branch April 25, 2025 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants