Fixed #23968 -- Replace list comprehension with generator comprehension when possible

might as well make these dict comprehensions