Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Perl use SV treating all types, IV, NV, SV, IO etc, and can switch type as any time. Most of time, it’s a very handy mechanism, neither type error nor need type cast. But when performance of program is a point, this will become irresistible.

Someone would say why not XS? Yes, XS is powerful, but it’s not silver bullet, especially, perl still consume amount of time to inbox and outbox value (perl at least use 4 words to store a int). for example, I’d like to read some strings from a CSV, then search in a DB by these strings, at last write the string retrieved from DB into a new file. In order to speed it up, I use XS module as much as possible. I use TEXT::CSV_XS for reading/wrting file, use DBI for read DB, frustratingly, the program in perl is still slow.

Why? Since perl convert strings in file to SV, then convert SV to string for Database, then convert strings read from DB to SV, at last, convert SV to string for write file. When I’ve learned perl internal recently, one idea is getting into my mind repeatedly. Why wouldn't add native type in to perl? not refcount, no magic, can't change type, and only in lexical. The native value only live in declearing lexical. Like: { my native str $bb = “ hello world”; # cstring; my $cc = “hello world”; #perl string } In this way, when doing the jobs to communicate external library/program like above, perl is more like transparent bridge and no any extra performance loss.

It’s just a thought when I read perlguts, Is it a good idea or not? Please monks enlighten me. TIA.


In reply to Why not perl have raw/native type by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (6)
    As of 2020-12-04 05:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      How often do you use taint mode?





      Results (58 votes). Check out past polls.

      Notices?