[cairo] cairo Digest, Vol 117, Issue 15

Elvis Teixeira elvismtt at gmail.com
Sat Apr 18 16:16:49 PDT 2015


Thank you very much for your comments Lawrence, although PySlope is just a
effort in learning python, so I know that there shoud be many
misundertandings :) And I am not sure if it was time to put it in the repo.

2015-04-18 16:00 GMT-03:00 <cairo-request at cairographics.org>:

> Send cairo mailing list submissions to
>         cairo at cairographics.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.cairographics.org/mailman/listinfo/cairo
> or, via email, send a message with subject or body 'help' to
>         cairo-request at cairographics.org
>
> You can reach the person managing the list at
>         cairo-owner at cairographics.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of cairo digest..."
>
>
> Today's Topics:
>
>    1. Re: A new charting library (Lawrence D'Oliveiro)
>    2. Creating A Cairo Context Seems Quite Quick (Lawrence D'Oliveiro)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 18 Apr 2015 08:48:54 +1200
> From: Lawrence D'Oliveiro <ldo at geek-central.gen.nz>
> To: cairo at cairographics.org
> Subject: Re: [cairo] A new charting library
> Message-ID: <20150418084854.05334420 at theon.geek-central.gen.nz>
> Content-Type: text/plain; charset=UTF-8
>
> On Fri, 17 Apr 2015 09:10:19 -0300, Elvis Teixeira wrote:
>
> > PROJECT INFO:
> > name: slope
> > type: Charting library
> > author: Elvis Teixeira (Brazil)
> > license: LGPL
> > link: https://github.com/elvismt/slope
>
> I was going to say this was a natural job for Python, and then I saw
> you were ahead of me. :)
>
> Some random comments:
>
> In PySlope/data.py, why not shorten Data.set_visible to
>
>     def set_visible(self, on):
>         c.slope_data_set_visible(self.cobj, on)
>
> Similarly for XyData.set_antialias in PySlope/xydata.py.
>
> Where you have a lot of instance attributes (e.g. XyChart, in
> PySlope/simple_charts.py), it can be a good idea to list these in a
> __slots__ class attribute. This way, when you try to assign to the wrong
> one, Python reports “no such attribute” rather than silently creating a
> new one. This helps prevent typos.
>
> In that same source file, how about shortening XyChart.axis to
>
>     def axis(self, name):
>         return \
>             self._metrics.get_axis \
>               (
>                 {
>                     'top' : xymetrics.LEFT_AXIS,
>                     'left' : xymetrics.TOP_AXIS,
>                     'bottom' : xymetrics.BOTTOM_AXIS,
>                     'right' : xymetrics.RIGHT_AXIS,
>                 }[name]
>               )
>
> You could even use enums, but that restricts you to Python 3.4 and
> later.
>
>
> ------------------------------
>
> Message: 2
> Date: Sat, 18 Apr 2015 22:30:58 +1200
> From: Lawrence D'Oliveiro <ldo at geek-central.gen.nz>
> To: cairo at cairographics.org
> Subject: [cairo] Creating A Cairo Context Seems Quite Quick
> Message-ID: <20150418223058.23781278 at theon.geek-central.gen.nz>
> Content-Type: text/plain; charset=UTF-8
>
> I just added methods to my Path and Path.Segment types in Qahirah
> <https://github.com/ldo/qahirah> to compute extents and return
> flattened versions. These create a temporary Cairo context so I can use
> its append_path and copy_path_flat calls to do all the work. The
> overhead of this doesn’t seem too bad.
>
> As a baseline (on an already-created Cairo context), the Python sequence
>
>     ctx.new_path().append_path(path).copy_path_flat()
>
> takes 140µs for a simple rectangular path on my Core i7 (averaged over
> 100,000 iterations using the Python timeit module), while
>
>     ctx.new_path().append_path(path).path_extents
>
> takes 59µs. For the new methods I have added, which create a new context
> on every call,
>
>     path.flatten()
>
> takes 162µs, while
>
>     path.extents
>
> takes 83µs. So the overhead in the former is about 16%, in the latter
> about 40%. Well short of the order-of-magnitude-or-more I was
> expecting/fearing...
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
> ------------------------------
>
> End of cairo Digest, Vol 117, Issue 15
> **************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20150418/003d225b/attachment.html>


More information about the cairo mailing list