user-pic

QM

  • About: Quantum Mechanics: The dreams stuff is made of!
Subscribe to feed Recent Actions from QM

  • Graham Knop commented on Extracting values from a list of (key, value) pairs

    There is a small mistake in your code. @N has an odd number of elements. pairkeys will warn about this if warnings are on.

    Another option for this is doing an array slice:

    @N[ map $_*2, 0..(@N/2)-1 ]
    It's slower than several other options though.

  • Aristotle commented on Extracting values from a list of (key, value) pairs

    I wonder how idxa performs if you add a $#v = $#N / 2; before the loop.

  • Diab Jerius commented on Extracting values from a list of (key, value) pairs

    @Graham Knop: I've fixed the code; thanks.

    @Aristotle: It actually seems to slow it down by a bit. Sequential runs with with your suggestion implemented, followed by the original code give:

    with: 1002/s 1016/s
    original: 1049/s 1075/s

    The difference between the two is probably significant within the noise of the measurements.

  • mascip commented on Extracting values from a list of (key, value) pairs

    Have you tried Var::Pairs, written by Damian Conway? It doesn't have a subroutine to extract all keys, but it's very god for loops:

    for my $next (pairs @array) {
    say $next->index, ' has the value ', $next->value;
    }

  • Manuel Ceron commented on On the relative readability of Perl and Python

    I’m a Python developer but I started coding Perl full time since a little bit more than a year. It’s true that Python has many quirks. That happens with any language that is more than 20 years old. But I think Perl probably has more quirks than Python.

    I think one reason why people think that Python is more readable is because it’s simpler. Both syntax and semantics are simpler. Less operators, less constructs, less ways of doing things. In practice this means that you can understand any Python code after an afternoon. While the same thing for Perl takes years.

Subscribe to feed Responses to Comments from QM

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.