Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

plain old C, to be called via ctypes #4

Copy link
Copy link
@jsbueno

Description

@jsbueno
Issue body actions

we can format this a sa pr later, but it is this thing:

unsigned long long count_double(char *str) {
    char *i, c1, c2;
    unsigned long long  count = 0;

    c1 = *str;
    c2 = *(str + 1);
    for(i = str+1; c2 = *i; i++) {
        count += (c1 == c2);
        c1 = c2;
    }
    return count;
}

Build with:
gcc -shared -o libblacount.so -fPIC blacount.c

And prepare to use from Python with:

import ctypes
blacount = ctypes.cdll.LoadLibrary("./libblacount.so")
blacount.count_double.argtypes = [ctypes.c_char_p]
blacount.count_double.restype = ctypes.c_uint64

(it counts byte-strings only)

rochacbruno

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.