Re: How to create a python extension module from a shared library?

2018-01-02 Thread Etienne Robillard

Hi James,

Thanks for your input.

I want to make a native Python application (uwsgictl) to dispatch FIFO 
commands to the master uWSGI process.


uwsgictl would depend on libuwsgi.so, a uWSGI plugin included in the 
distribution.


My goal is to use CFFI to generate python bindings for libuwsgi.so using 
clang interpreter. :)



Best regards,

Etienne


Le 2018-01-02 à 05:06, James Chapman a écrit :

Hi Etienne,

I'm not familiar with uSWGI, so I started here: 
https://uwsgi-docs.readthedocs.io/en/latest/Hooks.html
AFAIK there are a number of hooks already exposed and available to 
Python apps.


However, if I've understood your question correctly, you want to 
extend uWSGI itself by writing some python code which is then 
translated/generated into C code? You refer to AST generation but why 
are you doing this? Maybe my unfamiliarity with uWSGI is preventing me 
from understanding exactly what it is you are trying to do, but 
further clarification would go a long way.


If your goal is actually to extend uWSGI via a plugin, then there's 
more to just writing some python, you'll need to write some C code (I 
wouldn't bother trying to generate this as it'll probably not work):

https://github.com/unbit/uwsgi-docs/blob/master/tutorials/WritingPlugins.rst

If you look here, there's a link to each 3rd party plugin (mostly 
GitHub) where you can see the source code for each plugin. This is a 
very good starting point as there are many examples here:

https://uwsgi-docs.readthedocs.io/en/latest/ThirdPartyPlugins.html

Perhaps you can clarify.

James




On 30 December 2017 at 01:00, Etienne Robillard > wrote:


Hi all,

I would like to extend uWSGI by creating a CPython extension
module for the libuwsgi.so shared library included in the
distribution.

My goal is to use this automatically generated CPython module for
extending uWSGI.




--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
https://mail.python.org/mailman/listinfo/python-list


Re: How to create a python extension module from a shared library?

2018-01-02 Thread Etienne Robillard
Here's my ffi_build.py script: 
https://bitbucket.org/tkadm30/libuwsgictl/src/956f6ca24f9111c1d8b3ce90cf17173a6e5ae3e2/ffi_build.py?at=default&fileviewer=file-view-default


Not really sure how to preprocess the uwsgi.h header with clang.cindex 
in cffi.


I can load the shared lib with :


lib  =  clang.cindex.cdll.LoadLibrary(c_lib)


Any ideas how to compile lib into a python extension module with cffi?


Etienne

Le 2018-01-02 à 05:17, Etienne Robillard a écrit :

Hi James,

Thanks for your input.

I want to make a native Python application (uwsgictl) to dispatch FIFO 
commands to the master uWSGI process.


uwsgictl would depend on libuwsgi.so, a uWSGI plugin included in the 
distribution.


My goal is to use CFFI to generate python bindings for libuwsgi.so 
using clang interpreter. :)



Best regards,

Etienne


Le 2018-01-02 à 05:06, James Chapman a écrit :

Hi Etienne,

I'm not familiar with uSWGI, so I started here: 
https://uwsgi-docs.readthedocs.io/en/latest/Hooks.html
AFAIK there are a number of hooks already exposed and available to 
Python apps.


However, if I've understood your question correctly, you want to 
extend uWSGI itself by writing some python code which is then 
translated/generated into C code? You refer to AST generation but why 
are you doing this? Maybe my unfamiliarity with uWSGI is preventing 
me from understanding exactly what it is you are trying to do, but 
further clarification would go a long way.


If your goal is actually to extend uWSGI via a plugin, then there's 
more to just writing some python, you'll need to write some C code (I 
wouldn't bother trying to generate this as it'll probably not work):
https://github.com/unbit/uwsgi-docs/blob/master/tutorials/WritingPlugins.rst 



If you look here, there's a link to each 3rd party plugin (mostly 
GitHub) where you can see the source code for each plugin. This is a 
very good starting point as there are many examples here:

https://uwsgi-docs.readthedocs.io/en/latest/ThirdPartyPlugins.html

Perhaps you can clarify.

James




On 30 December 2017 at 01:00, Etienne Robillard > wrote:


    Hi all,

    I would like to extend uWSGI by creating a CPython extension
    module for the libuwsgi.so shared library included in the
    distribution.

    My goal is to use this automatically generated CPython module for
    extending uWSGI.






--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
https://mail.python.org/mailman/listinfo/python-list


unicode direction control characters

2018-01-02 Thread Robin Becker

I'm seeing some strange characters in web responses eg

u'\u200e28\u200e/\u200e09\u200e/\u200e1962'

for a date of birth. The code \u200e is LEFT-TO-RIGHT MARK according to 
unicodedata.name.  I tried unicodedata.normalize, but it leaves those characters 
there. Is there any standard way to deal with these?


I assume that some browser+settings combination is putting these in eg perhaps 
the language is normally right to left but numbers are not.

--
Robin Becker

--
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2018-01-02 Thread bartc

On 29/12/2017 18:11, Chris Angelico wrote:

On Sat, Dec 30, 2017 at 4:13 AM, bartc  wrote:

If you want to translate code from one language to another, and the source
language uses gotos, or uses control structures not available in the target
language, then gotos would be very useful in the latter.



As has already been said in this thread, a competent FORTRAN
programmer can write FORTRAN code in any language. But if you want to
actually write Python code, instead of writing FORTRAN code that gets
run through a Python interpreter, you have to grok the Python way of
doing things.


That's not true. People should be able to write code as they like using 
the nearest available language and using the style they are most adept 
in and that they find comfortable. /Especially/ if they are coding for 
themselves rather as part of some organisation or within a team.


The choice of language may enforce some changes, but that should be the 
extent of it.


A lot of the so-called 'Pythonic' style I frankly don't care for.

I like to write code in a simple, clean, universal style that everyone 
can understand.


That doesn't mean it has to look like Fortran.


You can't do that by mechanically transforming source
code into the syntax of a different language.


(Actually that's exactly what a project of mine from a few years ago was 
trying to do.


Example of 'binary trees' benchmark:

source syntax:https://pastebin.com/raw/bgfKw2pq

generated Python: https://pastebin.com/raw/XJWjWzpw)

Here, you normally had to be aware when writing in the source language, 
of what target language you were using. Although sometimes exactly the 
same source translated to several targets including Python and Lisp. 
Anyway, this was unsatisfactory as a universal syntax that could be 
translated to any language.)



People who try to tell you that all programming languages are
identical, just with different syntax, are doing you a disservice.
Lisp is not Python is not REXX is not C is not DeScribe Macro
Language. (Especially the latter. Do NOT try to write C code in DML.
It'll look ugly. Trust me.


My experiment showed that such people have a point.

--
bartc
--
https://mail.python.org/mailman/listinfo/python-list


Re: unicode direction control characters

2018-01-02 Thread Chris Angelico
On Wed, Jan 3, 2018 at 1:30 AM, Robin Becker  wrote:
> I'm seeing some strange characters in web responses eg
>
> u'\u200e28\u200e/\u200e09\u200e/\u200e1962'
>
> for a date of birth. The code \u200e is LEFT-TO-RIGHT MARK according to
> unicodedata.name.  I tried unicodedata.normalize, but it leaves those
> characters there. Is there any standard way to deal with these?
>
> I assume that some browser+settings combination is putting these in eg
> perhaps the language is normally right to left but numbers are not.

Unicode normalization is a different beast altogether. You could
probably just remove the LTR marks and run with the rest, though, as
they don't seem to be important in this string.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2018-01-02 Thread Chris Angelico
On Wed, Jan 3, 2018 at 1:51 AM, bartc  wrote:
> On 29/12/2017 18:11, Chris Angelico wrote:
>>
>> On Sat, Dec 30, 2017 at 4:13 AM, bartc  wrote:
>>>
>>> If you want to translate code from one language to another, and the
>>> source
>>> language uses gotos, or uses control structures not available in the
>>> target
>>> language, then gotos would be very useful in the latter.
>>>
>>
>> As has already been said in this thread, a competent FORTRAN
>> programmer can write FORTRAN code in any language. But if you want to
>> actually write Python code, instead of writing FORTRAN code that gets
>> run through a Python interpreter, you have to grok the Python way of
>> doing things.
>
>
> That's not true. People should be able to write code as they like using the
> nearest available language and using the style they are most adept in and
> that they find comfortable. /Especially/ if they are coding for themselves
> rather as part of some organisation or within a team.
>
> The choice of language may enforce some changes, but that should be the
> extent of it.
>
> A lot of the so-called 'Pythonic' style I frankly don't care for.
>
> I like to write code in a simple, clean, universal style that everyone can
> understand.
>
> That doesn't mean it has to look like Fortran.

Why are you using a Python interpreter then? Why are you here on
python-list, talking about Python? There must be SOME reason for using
this language rather than another.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to create a python extension module from a shared library?

2018-01-02 Thread Etienne Robillard

Hi James,


Le 2018-01-02 à 09:30, James Chapman a écrit :



What starts uWSGI? Is it started from a Python application or a 
webserver? Apologies for my lack of knowledge RE uWSGI.



uWSGI is typically managed by the web server.


> Any ideas how to compile lib into a python extension module with cffi?

No. Do you mean python binary extension? 
(https://packaging.python.org/guides/packaging-binary-extensions/)

Or Python package? (https://python-packaging.readthedocs.io/en/latest/)

I just want CFFI to work with clang to produce automagically the python 
bindings for my app.

James



Best regards,

Etienne

--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
https://mail.python.org/mailman/listinfo/python-list


Re: unicode direction control characters

2018-01-02 Thread Robin Becker

On 02/01/2018 15:18, Chris Angelico wrote:

On Wed, Jan 3, 2018 at 1:30 AM, Robin Becker  wrote:

I'm seeing some strange characters in web responses eg

u'\u200e28\u200e/\u200e09\u200e/\u200e1962'

for a date of birth. The code \u200e is LEFT-TO-RIGHT MARK according to
unicodedata.name.  I tried unicodedata.normalize, but it leaves those
characters there. Is there any standard way to deal with these?

I assume that some browser+settings combination is putting these in eg
perhaps the language is normally right to left but numbers are not.


Unicode normalization is a different beast altogether. You could
probably just remove the LTR marks and run with the rest, though, as
they don't seem to be important in this string.

ChrisA

I guess I'm really wondering whether the BIDI control characters have any 
semantic meaning. Most numbers seem to be LTR.


If I saw u'\u200f12' it seems to imply that the characters should be displayed 
'21', but I don't know whether the number is 12 or 21.

--
Robin Becker

--
https://mail.python.org/mailman/listinfo/python-list


Re: unicode direction control characters

2018-01-02 Thread Chris Angelico
On Wed, Jan 3, 2018 at 2:36 AM, Robin Becker  wrote:
> On 02/01/2018 15:18, Chris Angelico wrote:
>>
>> On Wed, Jan 3, 2018 at 1:30 AM, Robin Becker  wrote:
>>>
>>> I'm seeing some strange characters in web responses eg
>>>
>>> u'\u200e28\u200e/\u200e09\u200e/\u200e1962'
>>>
>>> for a date of birth. The code \u200e is LEFT-TO-RIGHT MARK according to
>>> unicodedata.name.  I tried unicodedata.normalize, but it leaves those
>>> characters there. Is there any standard way to deal with these?
>>>
>>> I assume that some browser+settings combination is putting these in eg
>>> perhaps the language is normally right to left but numbers are not.
>>
>>
>> Unicode normalization is a different beast altogether. You could
>> probably just remove the LTR marks and run with the rest, though, as
>> they don't seem to be important in this string.
>>
>> ChrisA
>>
> I guess I'm really wondering whether the BIDI control characters have any
> semantic meaning. Most numbers seem to be LTR.
>
> If I saw u'\u200f12' it seems to imply that the characters should be
> displayed '21', but I don't know whether the number is 12 or 21.
>

In this particular situation, it's highly unlikely that they'll have
any influence, and even if they do, I don't think there's any way for
the *repeated* directionality markers to do anything. They look like
something added automatically for the sake of paranoia.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to create a python extension module from a shared library?

2018-01-02 Thread James Chapman
Hi Etienne,

I'm not familiar with uSWGI, so I started here:
https://uwsgi-docs.readthedocs.io/en/latest/Hooks.html
AFAIK there are a number of hooks already exposed and available to Python
apps.

However, if I've understood your question correctly, you want to extend
uWSGI itself by writing some python code which is then translated/generated
into C code? You refer to AST generation but why are you doing this? Maybe
my unfamiliarity with uWSGI is preventing me from understanding exactly
what it is you are trying to do, but further clarification would go a long
way.

If your goal is actually to extend uWSGI via a plugin, then there's more to
just writing some python, you'll need to write some C code (I wouldn't
bother trying to generate this as it'll probably not work):
https://github.com/unbit/uwsgi-docs/blob/master/tutorials/WritingPlugins.rst

If you look here, there's a link to each 3rd party plugin (mostly GitHub)
where you can see the source code for each plugin. This is a very good
starting point as there are many examples here:
https://uwsgi-docs.readthedocs.io/en/latest/ThirdPartyPlugins.html

Perhaps you can clarify.

James




On 30 December 2017 at 01:00, Etienne Robillard  wrote:

> Hi all,
>
> I would like to extend uWSGI by creating a CPython extension module for
> the libuwsgi.so shared library included in the distribution.
>
> My goal is to use this automatically generated CPython module for
> extending uWSGI.
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to create a python extension module from a shared library?

2018-01-02 Thread James Chapman
I have an example of loading and communicating with a dynamic library using
ctypes in Windows here:
https://github.com/James-Chapman/python-code-snippets/tree/master/DLL_C_funcs_w_callbacks
It shouldn't be too dissimilar on Linux.

What starts uWSGI? Is it started from a Python application or a webserver?
Apologies for my lack of knowledge RE uWSGI.


> Any ideas how to compile lib into a python extension module with cffi?

No. Do you mean python binary extension? (
https://packaging.python.org/guides/packaging-binary-extensions/)
Or Python package? (https://python-packaging.readthedocs.io/en/latest/)

James
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to create a python extension module from a shared library?

2018-01-02 Thread James Chapman
Again, apologies if I've dumbed this down, but if I understand this all
correctly...

The webserver starts uWSGI, the python application running within then does
stuff via uWSGI. You want one of those things to be handled by a uWSGI
extension that has been written in python, with CFFI, rather than in pure
C. In other words, CFFI is going to generate the C part of the extension.

Unfortunately I'm no CFFI expert, but the above sounds like something that
might be better broken down into 2 parts.
1) Writing uWSGI extensions in Python and posted to a uWSGI development
forum.
2) Generating python bindings for C calls with CFFI and clang and posted to
a CFFI forum. (Why clang? GCC/G++ will work just as well and may be the
default).​

Hope that helps.

James
-- 
https://mail.python.org/mailman/listinfo/python-list


Where did csv.parser() go?

2018-01-02 Thread jason
I need record the starting offsets of csv rows in a database for fast seeking 
later. 
Unfortunately, using any csv.reader() (or DictReader) tries to cache, which 
means:
example_Data = "'data
0123456789ABCDE
1123456789ABCDE
2123456789ABCDE
3123456789ABCDE
...
'''

for line in reader:
offsets[row] = f.tell() 

is not possible. With my example data , offsets are reported as [0, 260, 260, 
260...] they should be [0x00, 0x00,0x15, 0x25, ...] (sample data is 16 byte 
rows after a 5 byte header (just for now)) 

I saw in one of PEP-305's references a mention of csv.parser() which won't 
return a row until parsing is complete. This is ideal since some lines will 
have quoted text containing commas and new lines.  I don't want to re-write the 
parser, since later usage will use csvDictReader, so we need to identically 
parse rows. How can I do that with the Python 2.7 csv module?

Or how can I accomplish this task through other means?
-- 
https://mail.python.org/mailman/listinfo/python-list


Numpy and Terabyte data

2018-01-02 Thread Rustom Mody
Someone who works in hadoop asked me:

If our data is in terabytes can we do statistical (ie numpy pandas etc)
analysis on it?

I said: No (I dont think so at least!) ie I expect numpy (pandas etc)
to not work if the data does not fit in memory

Well sure *python* can handle (streams of) terabyte data I guess
*numpy* cannot

Is there a more sophisticated answer?

["Terabyte" is a just a figure of speech for "too large for main memory"]

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2018-01-02 Thread bartc

On 02/01/2018 15:20, Chris Angelico wrote:

On Wed, Jan 3, 2018 at 1:51 AM, bartc  wrote:



I like to write code in a simple, clean, universal style that everyone can
understand.

That doesn't mean it has to look like Fortran.


Why are you using a Python interpreter then? Why are you here on
python-list, talking about Python? There must be SOME reason for using
this language rather than another.


I'm more familiar with Python than any other like languages.

If I desperately needed a dynamic language and I couldn't use my own, 
then I would use Python.


But I would need to use it on my own terms, regardless of whether the 
result is 'pythonic'. If the language had 'goto', then I would use it if 
I found it apt.


However, the discussion here is academic, so it doesn't matter who uses 
what.


Apart from anything else, Python is never going to officially adopt 
'goto'. (Regardless of some version of it being available as an add-on 
library. Most things seem to be.)



--
bartc
--
https://mail.python.org/mailman/listinfo/python-list


Re: Where did csv.parser() go?

2018-01-02 Thread Peter Otten
ja...@apkudo.com wrote:

> I need record the starting offsets of csv rows in a database for fast
> seeking later. Unfortunately, using any csv.reader() (or DictReader) tries
> to cache, which means: example_Data = "'data
> 0123456789ABCDE
> 1123456789ABCDE
> 2123456789ABCDE
> 3123456789ABCDE
> ...
> '''
> 
> for line in reader:
> offsets[row] = f.tell()
> 
> is not possible. With my example data , offsets are reported as [0, 260,
> 260, 260...] they should be [0x00, 0x00,0x15, 0x25, ...] (sample data is
> 16 byte rows after a 5 byte header (just for now))
> 
> I saw in one of PEP-305's references a mention of csv.parser() which won't
> return a row until parsing is complete. This is ideal since some lines
> will have quoted text containing commas and new lines.  I don't want to
> re-write the parser, since later usage will use csvDictReader, so we need
> to identically parse rows. How can I do that with the Python 2.7 csv
> module?
> 
> Or how can I accomplish this task through other means?

It's not the reader that performs the caching it's iteration over the file:

$ python -c 'f = open("tmp.csv")
> for line in f: print f.tell()
> '
73
73
73
73
73
73

You can work around that by using the file's readline() method:

$ python -c 'f = open("tmp.csv")
for line in iter(f.readline, ""): print f.tell()
'
5
21
37
53
69
73

Combined with csv.reader():

$ python -c 'import csv; f = open("tmp.csv")
for row in csv.reader(iter(f.readline, "")): print f.tell(), row
'
5 ['data']
21 ['0123456789ABCDE']
37 ['1123456789ABCDE']
53 ['2123456789ABCDE']
69 ['3123456789ABCDE']
73 ['...']


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy and Terabyte data

2018-01-02 Thread jason
I'm not sure if I'll be laughed at, but a statistical sampling of a randomized 
sample should resemble the whole.

If you need min/max then min ( min(each node) )
If you need average then you need sum( sum(each node)) sum(count(each node))*

*You'll likely need to use log here, as you'll probably overflow.

It doesn't really matter what numpy can nagle you just need to collate the data 
properly, defer the actual calculation until the node calculations are 
complete. 

Also, numpy should store values more densely than python itself.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python goto

2018-01-02 Thread Rob Gaddi

On 12/28/2017 04:35 AM, Skip Montanaro wrote:

Jorge> I would like to know if there is a goto command or something similar that
Jorge> I can use in Python.

Ned> Python does not have a goto statement. You have to use structured
Ned> statements: for, while, try/except, yield, return, etc.

Though it appears some wag has used function decorators to implement
goto statements:

https://pypi.python.org/pypi/goto-statement/1.1

Rather clever, it seems.

Skip



If only all that power had been used for good instead of evil...

--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python goto

2018-01-02 Thread Chris Angelico
On Wed, Jan 3, 2018 at 5:16 AM, Rob Gaddi
 wrote:
> On 12/28/2017 04:35 AM, Skip Montanaro wrote:
>>
>> Jorge> I would like to know if there is a goto command or something
>> similar that
>> Jorge> I can use in Python.
>>
>> Ned> Python does not have a goto statement. You have to use structured
>> Ned> statements: for, while, try/except, yield, return, etc.
>>
>> Though it appears some wag has used function decorators to implement
>> goto statements:
>>
>> https://pypi.python.org/pypi/goto-statement/1.1
>>
>> Rather clever, it seems.
>>
>> Skip
>>
>
> If only all that power had been used for good instead of evil...
>

An evto statement?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where did csv.parser() go?

2018-01-02 Thread jason
Wow, awesome!!!

Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy and Terabyte data

2018-01-02 Thread Irving Duran
I've never heard or done that type of testing for a large dataset solely on
python, so I don't know what's the cap from the memory standpoint that
python can handle base on memory availability.  Now, if I understand what
you are trying to do, you can achieve that by leveraging Apache Spark and
invoking "pyspark" where you can store data in memory and/or hard disk.
Also, if you are working with Hadoop, you can use spark to move/transfer
data back-and-forth.


Thank You,

Irving Duran

On Tue, Jan 2, 2018 at 12:06 PM,  wrote:

> I'm not sure if I'll be laughed at, but a statistical sampling of a
> randomized sample should resemble the whole.
>
> If you need min/max then min ( min(each node) )
> If you need average then you need sum( sum(each node)) sum(count(each
> node))*
>
> *You'll likely need to use log here, as you'll probably overflow.
>
> It doesn't really matter what numpy can nagle you just need to collate the
> data properly, defer the actual calculation until the node calculations are
> complete.
>
> Also, numpy should store values more densely than python itself.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy and Terabyte data

2018-01-02 Thread Paul Moore
On 2 January 2018 at 17:24, Rustom Mody  wrote:
> Someone who works in hadoop asked me:
>
> If our data is in terabytes can we do statistical (ie numpy pandas etc)
> analysis on it?
>
> I said: No (I dont think so at least!) ie I expect numpy (pandas etc)
> to not work if the data does not fit in memory
>
> Well sure *python* can handle (streams of) terabyte data I guess
> *numpy* cannot
>
> Is there a more sophisticated answer?
>
> ["Terabyte" is a just a figure of speech for "too large for main memory"]

You might want to look at Dask (https://pypi.python.org/pypi/dask,
docs at http://dask.pydata.org/en/latest/).

I've not used it myself, but I believe it's designed for very much the
sort of use case you describe.
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2018-01-02 Thread John Wong
I think the point is there is not much to discuss. Goto is not going to be
added. Furthermore, for every program language you want to translate from
source, you have to find a workaround. Otherwise, your translation will
only work for languages that have goto. Even so the implementation may not
be exact what C goto is. Who knows. Much like in Go - the other day, slice
there has a different behavior to Python’s slice. I brought this up to show
that don’t expect everything to be equal.

John

On Tue, Jan 2, 2018 at 12:35 bartc  wrote:

> On 02/01/2018 15:20, Chris Angelico wrote:
> > On Wed, Jan 3, 2018 at 1:51 AM, bartc  wrote:
>
> >> I like to write code in a simple, clean, universal style that everyone
> can
> >> understand.
> >>
> >> That doesn't mean it has to look like Fortran.
> >
> > Why are you using a Python interpreter then? Why are you here on
> > python-list, talking about Python? There must be SOME reason for using
> > this language rather than another.
>
> I'm more familiar with Python than any other like languages.
>
> If I desperately needed a dynamic language and I couldn't use my own,
> then I would use Python.
>
> But I would need to use it on my own terms, regardless of whether the
> result is 'pythonic'. If the language had 'goto', then I would use it if
> I found it apt.
>
> However, the discussion here is academic, so it doesn't matter who uses
> what.
>
> Apart from anything else, Python is never going to officially adopt
> 'goto'. (Regardless of some version of it being available as an add-on
> library. Most things seem to be.)
>
>
> --
> bartc
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Sent from Jeff Dean's printf() mobile console
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to create a python extension module from a shared library?

2018-01-02 Thread Etienne Robillard

Hi James,

Part of the problem is because the CFFI and uWSGI developers aren't 
interested to support this. I need to modify CFFI to support 
preprocessing C headers with clang.cindex myself.


I also need to make sure its possible to attach my Python script to the 
master uWSGI process to dispatch FIFO commands.


Clang is needed because CFFI doesn't support preprocessing C headers 
with #define or #include directives.


Best regards,

Etienne


Le 2018-01-02 à 10:45, James Chapman a écrit :
Again, apologies if I've dumbed this down, but if I understand this 
all correctly...


The webserver starts uWSGI, the python application running within then 
does stuff via uWSGI. You want one of those things to be handled by a 
uWSGI extension that has been written in python, with CFFI, rather 
than in pure C. In other words, CFFI is going to generate the C part 
of the extension.


Unfortunately I'm no CFFI expert, but the above sounds like something 
that might be better broken down into 2 parts.
1) Writing uWSGI extensions in Python and posted to a uWSGI 
development forum.
2) Generating python bindings for C calls with CFFI and clang and 
posted to a CFFI forum. (Why clang? GCC/G++ will work just as well and 
may be the default).​


Hope that helps.

James





--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
https://mail.python.org/mailman/listinfo/python-list


Re: unicode direction control characters

2018-01-02 Thread Random832
On Tue, Jan 2, 2018, at 10:36, Robin Becker wrote:
> >> u'\u200e28\u200e/\u200e09\u200e/\u200e1962'
>
> I guess I'm really wondering whether the BIDI control characters have any 
> semantic meaning. Most numbers seem to be LTR.
> 
> If I saw u'\u200f12' it seems to imply that the characters should be 
> displayed 
> '21', but I don't know whether the number is 12 or 21.

No, 200F acts as a single R-L character (like an invisible letter), not an 
override for adjacent characters (as 202E would). LRM/RLM basically act like an 
invisible letter of the relevant directionality.

European numerals have "weak" LTR directionality (to allow them to be used as 
part of e.g. a list of numbers in a sentence written in an RTL language), and 
don't affect some punctuation marks the same way as letters. I believe the 
purpose here is to ensure that it displays as 28/09/1962 instead of 1962/09/28 
when the surrounding context is right-to-left. For the slash in particular, 
this was apparently a bug that was fixed in some recent version of unicode 
(this is mentioned briefly in UTR9, look for "solidus"), so earlier 
implementations or non-unicode implementations may not have supported it 
correctly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy and Terabyte data

2018-01-02 Thread Rustom Mody
On Wednesday, January 3, 2018 at 1:43:40 AM UTC+5:30, Paul  Moore wrote:
> On 2 January 2018 at 17:24, Rustom Mody wrote:
> > Someone who works in hadoop asked me:
> >
> > If our data is in terabytes can we do statistical (ie numpy pandas etc)
> > analysis on it?
> >
> > I said: No (I dont think so at least!) ie I expect numpy (pandas etc)
> > to not work if the data does not fit in memory
> >
> > Well sure *python* can handle (streams of) terabyte data I guess
> > *numpy* cannot
> >
> > Is there a more sophisticated answer?
> >
> > ["Terabyte" is a just a figure of speech for "too large for main memory"]
> 
> You might want to look at Dask (https://pypi.python.org/pypi/dask,
> docs at http://dask.pydata.org/en/latest/).

Thanks
Looks like what I was asking about
-- 
https://mail.python.org/mailman/listinfo/python-list