how to change the number of posts returned in a specific loop without making it global?

You need to pass an array to WP_Query like this

then after you’ve ended the query use this to reset the query data.

<?php wp_reset_query(); ?>

example of standard query using WP_Query

$arg = array(
'posts_per_page' => 20
);

$query = new WP_Query($args)
//start to loop your things here
 <?php if ($query->have_posts()) : ?>
 <?php while ($query->have_posts()) : $query->the_post(); ?>
// your custom code here
endif; endwhile;