Re: What are the minimum requirements to get a job in?

Discussion in 'Python' started by Cameron Simpson, Dec 15, 2012.

  1. On 14Dec2012 16:57, Dennis Lee Bieber <> wrote:
    | On Fri, 14 Dec 2012 12:42:27 +0100, Christian Heimes
    | <> declaimed the following in
    | gmane.comp.python.general:
    | >
    | > To be fair, memcpy() is a pretty simple function. It can be implemented
    | > in just about two lines of C code plus five lines of boiler plate. It
    | > shows, if you have very basic understanding about memory layout and
    | > pointer arithmetics.
    | >
    | > You have to translate something like
    | >
    | > def memcpy(dest, src, n):
    | > for i in xrange(n):
    | > dest = src
    | >
    | > into C code. Here is a rather nonperformance solution. It copies just
    | > one byte per cycle. A better implementation could copy 4 or 8 bytes at
    | > once and handle the tail in a switch statement.
    | >
    | > void *memcpy(void *dest, const void *src, size_t n)
    | > {
    | > char *destptr = (char*)dest;
    | > char *srcptr = (char*)src;
    | > while (n--) {
    | > *destptr++ = *srcptr++;
    | > }
    | > return dest;
    | > }
    | >
    | > destptr and srcptr are the memory addresses of a byte (char). *destptr
    | > is the value at a specific memory location. The code in the loop copies
    | > the value at address srcptr to the location at destptr and then moves
    | > both pointers one step to the right (++). That's all. ;)
    |
    | That is ignoring the possibility of overlapping source/destination
    | ranges (in which one may need to copy from the end rather than the
    | start).

    If you're going to be picky, memcpy() is not required to allow for that.
    That allows a high speed implementation. memmove() exists to cover the
    more general case.
    --
    Cameron Simpson <>

    NOTWORK: n. A network when it is acting flaky. Origin (?) IBM.
    - Hackers' Dictionary
     
    Cameron Simpson, Dec 15, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fred
    Replies:
    2
    Views:
    4,609
    Hermit Dave
    Jan 14, 2004
  2. gswork
    Replies:
    6
    Views:
    677
    Will Hartung
    Oct 7, 2004
  3. Philippe C. Martin

    Python install minimum requirements

    Philippe C. Martin, Nov 21, 2005, in forum: Python
    Replies:
    2
    Views:
    590
    Philippe C. Martin
    Nov 22, 2005
  4. rodchar

    minimum requirements

    rodchar, Nov 19, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    414
    rodchar
    Nov 19, 2007
  5. Replies:
    21
    Views:
    274
    Chris Angelico
    Dec 15, 2012
Loading...

Share This Page